Skip to content

Commit e8a7610

Browse files
committed
add ability to set prefs
1 parent 8fc631c commit e8a7610

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- `DisplayManager` class for managing Xvfb instance if needed
1111
- `ArduinoCmd` captures and caches preferences
1212
- `ArduinoCmd` reports on whether a board is installed
13+
- `ArduinoCmd` sets preferences
1314

1415
### Changed
1516
- `DisplayManger.with_display` doesn't `disable` if the display was enabled prior to starting the block

exe/ci_system_check.rb

+8
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@
1919
got_problem = true if v != result
2020
end
2121

22+
urls = [
23+
"https://adafruit.github.io/arduino-board-index/package_adafruit_index.json",
24+
"http://arduino.esp8266.com/stable/package_esp8266com_index.json"
25+
]
26+
27+
result = arduino_cmd.set_pref("boardsmanager.additional.urls", urls.join(","))
28+
got_problem = true unless result
29+
2230
abort if got_problem
2331
exit(0)

lib/arduino_ci/arduino_cmd.rb

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ def prefs
5151
ret
5252
end
5353

54+
# set a preference key/value pair
55+
# @param key [String] the preference key
56+
# @param value [String] the preference value
57+
# @return [bool] whether the command succeeded
58+
def set_pref(key, value)
59+
success = run_with_gui_guess(" about preferences", "--pref", "#{key}=#{value}", "--save-prefs")
60+
@prefs_cache[key] = value if success
61+
success
62+
end
63+
5464
# run the arduino command
5565
# @return [Hash] {:out => StringIO, :err => StringIO }
5666
def run(*args, **kwargs)

spec/arduino_cmd_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,15 @@
2727
expect(arduino_cmd.board_installed? "eggs:milk:wheat").to be false
2828
end
2929
end
30+
31+
context "set_pref" do
32+
arduino_cmd = ArduinoCI::ArduinoCmd.autolocate!
33+
ArduinoCI::DisplayManager::instance.enable
34+
35+
it "Sets key to what it was before" do
36+
upload_verify = arduino_cmd.prefs_cache["upload.verify"]
37+
result = arduino_cmd.set_pref("upload.verify", upload_verify)
38+
expect(result).to be true
39+
end
40+
end
3041
end

0 commit comments

Comments
 (0)