Skip to content

Commit 07fefac

Browse files
committed
Add flag to CIConfig to indicate whether it is the default
1 parent 630591b commit 07fefac

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
- `assertion()`, `ReporterTAP.onAssert()`, and `testBehaviorExp` macro to handle simple expression evaluation (is true, is false, etc)
1717
- `Wire.resetMocks()` and documentation
1818
- `shiftIn()` and `shiftOut()`
19+
- `CIConfig.is_default` to detect when the default configuration is used
1920

2021
### Changed
2122
- Rubocop expected syntax downgraded from ruby 2.6 to 2.5

lib/arduino_ci/ci_config.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,23 @@ class << self
5757
# @return [ArudinoCI::CIConfig] The configuration with defaults filled in
5858
def default
5959
ret = new
60+
ret.instance_variable_set("@is_default", true)
6061
ret.load_yaml(File.expand_path("../../misc/default.yml", __dir__))
6162
ret
6263
end
6364
end
6465

66+
attr_reader :is_default
6567
attr_accessor :package_info
6668
attr_accessor :platform_info
6769
attr_accessor :compile_info
6870
attr_accessor :unittest_info
6971

7072
def initialize
71-
@package_info = {}
73+
@is_default = false
74+
@package_info = {}
7275
@platform_info = {}
73-
@compile_info = {}
76+
@compile_info = {}
7477
@unittest_info = {}
7578
end
7679

spec/ci_config_spec.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
it "loads from yaml" do
1010
default_config = ArduinoCI::CIConfig.default
1111
expect(default_config).not_to be nil
12+
expect(default_config.is_default).to be true
1213
uno = default_config.platform_definition("uno")
1314
expect(uno.class).to eq(Hash)
1415
expect(uno[:board]).to eq("arduino:avr:uno")
@@ -39,8 +40,8 @@
3940
end
4041
end
4142

42-
context "clone" do
43-
it "creates a copy" do
43+
context "hash" do
44+
it "converts to hash" do
4445
base = ArduinoCI::CIConfig.new
4546
base.load_yaml(File.join(File.dirname(__FILE__), "yaml", "o2.yaml"))
4647

@@ -82,8 +83,11 @@
8283
context "with_override" do
8384
it "loads from yaml" do
8485
override_file = File.join(File.dirname(__FILE__), "yaml", "o1.yaml")
85-
combined_config = ArduinoCI::CIConfig.default.with_override(override_file)
86+
base = ArduinoCI::CIConfig.default
87+
expect(base.is_default).to be true
88+
combined_config = base.with_override(override_file)
8689
expect(combined_config).not_to be nil
90+
expect(combined_config.is_default).to be false
8791
uno = combined_config.platform_definition("uno")
8892
expect(uno.class).to eq(Hash)
8993
expect(uno[:board]).to eq("arduino:avr:uno")

0 commit comments

Comments
 (0)