From 3a385532af1514e59d5b511748826f75c8d1d50a Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Thu, 21 Jan 2021 11:08:21 -0500 Subject: [PATCH 1/3] Avoid error when no examples directory exists --- CHANGELOG.md | 1 + lib/arduino_ci/cpp_library.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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/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 From 0d18c318882b8170009f6f80646885fa43d27bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20L=C3=B8vdal?= Date: Mon, 5 Apr 2021 20:34:09 +0200 Subject: [PATCH 2/3] Remove variable no longer used Ought to have been removed in commit 659cb176 (Abandon library.properties scanning in favor of arduino-lint tool). --- exe/arduino_ci.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 175cdb2c..8ecc5328 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 From 85824824e3ef6d6c72aa99dc761a25d837a83e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20L=C3=B8vdal?= Date: Wed, 5 Oct 2022 23:58:17 +0200 Subject: [PATCH 3/3] Spelling correction --- exe/arduino_ci.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 8ecc5328..ea9964f0 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -91,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 @@ -112,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