Skip to content

Commit 804ba3b

Browse files
committed
expose board manager URL settings in ArduinoCmd
1 parent 9cfc460 commit 804ba3b

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

CHANGELOG.md

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

77
## [Unreleased]
88
### Added
9+
- Arduino command wrapper now natively supports board manager URLs
910

1011
### Changed
1112
- Centralized file listing code in `arduino_ci_remote.rb`

exe/arduino_ci_remote.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def display_files(pathname)
161161
all_urls = all_packages.map { |p| config.package_url(p) }.uniq.reject(&:nil?)
162162
unless all_urls.empty?
163163
assure("Setting board manager URLs") do
164-
@arduino_cmd.set_pref("boardsmanager.additional.urls", all_urls.join(","))
164+
@arduino_cmd.board_manager_urls = all_urls
165165
end
166166
end
167167

lib/arduino_ci/arduino_cmd.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ def run_and_capture(*args, **kwargs)
145145
ret
146146
end
147147

148+
# Board manager URLs
149+
# @return [Array<String>] The additional URLs used by the board manager
150+
def board_manager_urls
151+
url_list = get_pref("boardsmanager.additional.urls")
152+
return [] if url_list.nil?
153+
154+
url_list.split(",")
155+
end
156+
157+
# Set board manager URLs
158+
# @return [Array<String>] The additional URLs used by the board manager
159+
def board_manager_urls=(all_urls)
160+
set_pref("boardsmanager.additional.urls", all_urls.join(","))
161+
end
162+
148163
# check whether a board is installed
149164
# we do this by just selecting a board.
150165
# the arduino binary will error if unrecognized and do a successful no-op if it's installed

spec/arduino_cmd_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ def get_sketch(dir, file)
6565
end
6666
end
6767

68+
69+
context "board_manager" do
70+
it "Reads and writes board_manager URLs" do
71+
fake_urls = ["http://foo.bar", "http://arduino.ci"]
72+
existing_urls = arduino_cmd.board_manager_urls
73+
74+
# try to ensure maxiumum variability in the test
75+
test_url_sets = (existing_urls.empty? ? [fake_urls, []] : [[], fake_urls]) + [existing_urls]
76+
77+
test_url_sets.each do |urls|
78+
arduino_cmd.board_manager_urls = urls
79+
expect(arduino_cmd.board_manager_urls).to match_array(urls)
80+
end
81+
end
82+
end
83+
84+
6885
context "verify_sketch" do
6986

7087
sketch_path_ino = get_sketch("FakeSketch", "FakeSketch.ino")

0 commit comments

Comments
 (0)