Skip to content

Avoid error when no examples directory entries exists #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Apply "rule of three" to Client copy constructor and copy assignment operator
- Run Windows tests on Windows not Ubuntu
- Properly report error in building shared library
- A missing `examples` directory no longer causes a crash in `cpp_library.rb`

### Security

Expand Down
5 changes: 2 additions & 3 deletions exe/arduino_ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def self.parse(options)
puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd"
puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present"
puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present"
puts " - #{VAR_SKIP_LIBPROPS} - if set, testing will skip [experimental] library.properties validation"
exit
end
end
Expand Down Expand Up @@ -92,7 +91,7 @@ def terminate(final = nil)
end

# make a nice status line for an action and react to the action
# TODO / note to self: inform_multline is tougher to write
# TODO / note to self: inform_multiline is tougher to write
# without altering the signature because it only leaves space
# for the checkmark _after_ the multiline, it doesn't know how
# to make that conditionally the body
Expand All @@ -113,7 +112,7 @@ def perform_action(message, multiline, mark_fn, on_fail_msg, tally_on_fail, abor
$stdout.flush
result = yield
mark = mark_fn.nil? ? "" : mark_fn.call(result)
# if multline, put checkmark at full width
# if multiline, put checkmark at full width
print endline if multiline
puts mark.to_s.rjust(WIDTH - line.length, " ")
unless result
Expand Down
5 changes: 4 additions & 1 deletion lib/arduino_ci/cpp_library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def info
# @param installed_library_path [String] The library to query
# @return [Array<String>] Example sketch files
def example_sketches
reported_dirs = info["library"]["examples"].map(&Pathname::method(:new))
examples = info["library"]["examples"]
return [] if examples.nil?

reported_dirs = examples.map(&Pathname::method(:new))
reported_dirs.map { |e| e + e.basename.sub_ext(".ino") }.select(&:exist?).sort_by(&:to_s)
end

Expand Down