Skip to content

Commit 164c3a1

Browse files
committed
Detect and use (don't re-install) pre-existing Arduino libraries
1 parent 08930e5 commit 164c3a1

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [Unreleased]
88
### Added
99
- Explicit checks that the requested test platforms are defined in YML
10+
- Method to guess whether a library is installed
1011

1112
### Changed
1213
- Refactored documentation
14+
- External libraries aren't forcibly installed via the Arduino binary (in `arduino_cmd_remote.rb`) if they appear to exist on disk already
1315

1416
### Deprecated
1517

exe/arduino_ci_remote.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ def assured_platform(purpose, name, config)
119119
end
120120

121121
aux_libraries.each do |l|
122-
assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
122+
if @arduino_cmd.library_present?(l)
123+
assure("Using pre-existing library '#{l}'") { true }
124+
else
125+
assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
126+
end
123127
end
124128

125129
# iterate boards / tests

lib/arduino_ci/arduino_cmd.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ def library_path(library_name)
193193
File.join(_lib_dir, library_name)
194194
end
195195

196+
# Determine whether a library is present in the lib dir
197+
#
198+
# Note that `true` doesn't guarantee that the library is valid/installed
199+
# and `false` doesn't guarantee that the library isn't built-in
200+
#
201+
# @param library_name [String] The name of the library
202+
# @return [bool]
203+
def library_present?(library_name)
204+
File.exist?(library_path(library_name))
205+
end
206+
196207
# update the library index
197208
# @return [bool] Whether the update succeeded
198209
def update_library_index

spec/arduino_cmd_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def get_sketch(dir, file)
4646
end
4747
end
4848

49+
context "libraries" do
50+
it "knows where to find libraries" do
51+
fake_lib = "_____nope"
52+
expected_dir = File.join(arduino_cmd._lib_dir, fake_lib)
53+
expect(arduino_cmd.library_path(fake_lib)).to eq(expected_dir)
54+
expect(arduino_cmd.library_present?(fake_lib)).to be false
55+
end
56+
end
57+
4958
context "set_pref" do
5059

5160
it "Sets key to what it was before" do

0 commit comments

Comments
 (0)