Skip to content

Commit 8e415b3

Browse files
committed
Remove flag --no-dry-run for arduino_ci >= 0.14.0
1 parent 21b63e6 commit 8e415b3

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- Support for `dtostrf()`
1515
- Added a CI workflow to lint the code base
1616
- Added a CI workflow to check for spelling errors
17+
- Remove `--dry-run` flag for `arduino_ci` version `>= 0.14.0`
1718

1819
### Changed
1920
- We now compile a shared library to be used for each test.

Diff for: lib/arduino_ci/arduino_backend.rb

+14-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ def compile_sketch(path, boardname)
163163
@last_msg = "Can't compile Sketch at nonexistent path '#{path}'!"
164164
return false
165165
end
166-
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", "--dry-run", path.to_s)
166+
if should_use_dry_run?
167+
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", "--dry-run", path.to_s)
168+
else
169+
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", path.to_s)
170+
end
167171
@last_msg = ret[:out]
168172
ret[:success]
169173
end
@@ -235,5 +239,14 @@ def install_local_library(path)
235239
Host.symlink(src_path, destination_path)
236240
cpp_library
237241
end
242+
243+
private
244+
245+
def should_use_dry_run?
246+
ret = capture_json("version")
247+
version = ret[:json]["VersionString"]
248+
match = /(\d)\.(\d+)\.(\d+)/.match(version)
249+
return match[1].to_i == 0 && match[2].to_i < 14
250+
end
238251
end
239252
end

Diff for: spec/arduino_backend_spec.rb

+43
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,48 @@ def get_sketch(dir, file)
103103
it "Passes a simple INO sketch at #{sketch_path_ino}" do
104104
expect(backend.compile_sketch(sketch_path_ino, "arduino:avr:uno")).to be true
105105
end
106+
107+
context "--dry-run flags" do
108+
before { allow(backend).to receive(:run_and_capture).and_call_original }
109+
110+
it "Uses --dry-run flag for arduino_cli version < 0.14.0" do
111+
parsed_stdout = JSON.parse('{ "VersionString": "0.13.6" }')
112+
cli_version_output = {
113+
json: parsed_stdout
114+
}
115+
allow(backend).to receive(:capture_json).and_return cli_version_output
116+
117+
backend.compile_sketch(sketch_path_ino, "arduino:avr:uno")
118+
119+
expect(backend).to have_received(:run_and_capture).with(
120+
"compile",
121+
"--fqbn",
122+
"arduino:avr:uno",
123+
"--warnings",
124+
"all",
125+
"--dry-run",
126+
sketch_path_ino
127+
)
128+
end
129+
130+
it "Does not use --dry-run flag for arduino_cli version >= 0.14.0" do
131+
parsed_stdout = JSON.parse('{ "VersionString": "0.14.0" }')
132+
cli_version_output = {
133+
json: parsed_stdout
134+
}
135+
allow(backend).to receive(:capture_json).and_return cli_version_output
136+
137+
backend.compile_sketch(sketch_path_ino, "arduino:avr:uno")
138+
139+
expect(backend).to have_received(:run_and_capture).with(
140+
"compile",
141+
"--fqbn",
142+
"arduino:avr:uno",
143+
"--warnings",
144+
"all",
145+
sketch_path_ino
146+
)
147+
end
148+
end
106149
end
107150
end

0 commit comments

Comments
 (0)