Skip to content

Commit 83fd308

Browse files
hf-4145ianfixes
authored andcommitted
Remove flag --no-dry-run for arduino-ci >= 0.14.0
1 parent d4c3fea commit 83fd308

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

lib/arduino_ci/arduino_backend.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ def compile_sketch(path, boardname)
211211
@last_msg = "Can't compile Sketch at nonexistent path '#{path}'!"
212212
return false
213213
end
214-
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", path.to_s)
214+
use_dry_run = should_use_dry_run?
215+
if use_dry_run
216+
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", "--dry-run", path.to_s)
217+
else
218+
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", path.to_s)
219+
end
215220
@last_msg = ret[:out]
216221
ret[:success]
217222
end
@@ -299,5 +304,11 @@ def last_bytes_usage
299304

300305
Hash[mem_info.names.map(&:to_sym).zip(mem_info.captures.map(&:to_i))]
301306
end
307+
308+
def should_use_dry_run?
309+
ret = capture_json("version")
310+
version = ret[:json]["VersionString"]
311+
Gem::Version.new(version) < Gem::Version.new('0.14')
312+
end
302313
end
303314
end

spec/arduino_backend_spec.rb

+46
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,50 @@ def get_sketch(dir, file)
110110
expect(the_bytes[:max]).to eq 2048
111111
end
112112
end
113+
114+
context "--dry-run flags" do
115+
116+
sketch_path_ino = get_sketch("FakeSketch", "FakeSketch.ino")
117+
118+
before { allow(backend).to receive(:run_and_capture).and_call_original }
119+
120+
it "Uses --dry-run flag for arduino-cli version < 0.14.0" do
121+
parsed_stdout = JSON.parse('{ "VersionString": "0.13.6" }')
122+
cli_version_output = {
123+
json: parsed_stdout
124+
}
125+
allow(backend).to receive(:capture_json).and_return cli_version_output
126+
127+
backend.compile_sketch(sketch_path_ino, "arduino:avr:uno")
128+
129+
expect(backend).to have_received(:run_and_capture).with(
130+
"compile",
131+
"--fqbn",
132+
"arduino:avr:uno",
133+
"--warnings",
134+
"all",
135+
"--dry-run",
136+
sketch_path_ino.to_s
137+
)
138+
end
139+
140+
it "Does not use --dry-run flag for arduino-cli version >= 0.14.0" do
141+
parsed_stdout = JSON.parse('{ "VersionString": "0.14.0" }')
142+
cli_version_output = {
143+
json: parsed_stdout
144+
}
145+
allow(backend).to receive(:capture_json).and_return cli_version_output
146+
147+
backend.compile_sketch(sketch_path_ino, "arduino:avr:uno")
148+
149+
expect(backend).to have_received(:run_and_capture).with(
150+
"compile",
151+
"--fqbn",
152+
"arduino:avr:uno",
153+
"--warnings",
154+
"all",
155+
sketch_path_ino.to_s
156+
)
157+
end
158+
end
113159
end

0 commit comments

Comments
 (0)