Skip to content

Commit c11165e

Browse files
committed
Detect and alert mistaken attempts to test the core lib as an arduino project
1 parent 0151740 commit c11165e

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Added
10+
- Special handling of attempts to run the `arduino_ci.rb` CI script against the ruby library instead of an actual Arduino project
11+
- Explicit checks for attemping to test `arduino_ci` itself as if it were a library, resolving a minor annoyance to this developer.
1012

1113
### Changed
1214
- Arduino backend is now `arduino-cli` version `0.13.0`

exe/arduino_ci.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,25 @@ def perform_unit_tests(file_config)
214214

215215
# iterate boards / tests
216216
if !cpp_library.tests_dir.exist?
217-
inform_multiline("Skipping unit tests; no tests dir at #{cpp_library.tests_dir}") do
218-
puts " In case that's an error, this is what was found in the library:"
219-
display_files(cpp_library.tests_dir.parent)
220-
true
217+
# alert future me about running the script from the wrong directory, instead of doing the huge file dump
218+
# otherwise, assume that the user might be running the script on a library with no actual unit tests
219+
if (Pathname.new(__dir__).parent == Pathname.new(Dir.pwd))
220+
inform_multiline("arduino_ci seems to be trying to test itself") do
221+
[
222+
"arduino_ci (the ruby gem) isn't an arduino project itself, so running the CI test script against",
223+
"the core library isn't really a valid thing to do... but it's easy for a developer (including the",
224+
"owner) to mistakenly do just that. Hello future me, you probably meant to run this against one of",
225+
"the sample projects in SampleProjects/ ... if not, please submit a bug report; what a wild case!"
226+
].each { |l| puts " #{l}" }
227+
false
228+
end
229+
exit(1)
230+
else
231+
inform_multiline("Skipping unit tests; no tests dir at #{cpp_library.tests_dir}") do
232+
puts " In case that's an error, this is what was found in the library:"
233+
display_files(cpp_library.tests_dir.parent)
234+
true
235+
end
221236
end
222237
elsif cpp_library.test_files.empty?
223238
inform_multiline("Skipping unit tests; no test files were found in #{cpp_library.tests_dir}") do

0 commit comments

Comments
 (0)