diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ee831b..24c41012 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 175cdb2c..ea9964f0 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -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 @@ -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 @@ -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 diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb index ed43f72c..cd0809a4 100644 --- a/lib/arduino_ci/cpp_library.rb +++ b/lib/arduino_ci/cpp_library.rb @@ -135,7 +135,10 @@ def info # @param installed_library_path [String] The library to query # @return [Array] 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