Skip to content

Commit f9df387

Browse files
committed
Env vars to escalate certain files not being discovered during CI
1 parent c1d3700 commit f9df387

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased]
99
### Added
1010
- `ensure_arduino_installation.rb` now ensures the existence of the library directory as well
11+
- Environment variables to escalate unit tests or examples not being found during CI testing
1112

1213
### Changed
1314
- Conserve CI testing minutes by grouping CI into fewer runs

exe/arduino_ci.rb

+25-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
WIDTH = 80
88
FIND_FILES_INDENT = 4
9+
VAR_EXPECT_EXAMPLES = "EXPECT_EXAMPLES".freeze
10+
VAR_EXPECT_UNITTESTS = "EXPECT_UNITTESTS".freeze
911

1012
@failure_count = 0
1113
@passfail = proc { |result| result ? "✓" : "✗" }
@@ -48,6 +50,10 @@ def self.parse(options)
4850

4951
opts.on("-h", "--help", "Prints this help") do
5052
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"
5157
exit
5258
end
5359
end
@@ -189,6 +195,23 @@ def install_arduino_library_dependencies(library_names, on_behalf_of, already_in
189195
installed
190196
end
191197

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+
192215
def perform_unit_tests(cpp_library, file_config)
193216
if @cli_options[:skip_unittests]
194217
inform("Skipping unit tests") { "as requested via command line" }
@@ -239,11 +262,7 @@ def perform_unit_tests(cpp_library, file_config)
239262
end
240263
end
241264
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)
247266
elsif config.platforms_to_unittest.empty?
248267
inform("Skipping unit tests") { "no platforms were requested" }
249268
else
@@ -337,9 +356,7 @@ def perform_example_compilation_tests(cpp_library, config)
337356
inform("Skipping builds") { "no platforms were requested" }
338357
return
339358
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)
343360
return
344361
end
345362

0 commit comments

Comments
 (0)