Skip to content

Commit b1ea18b

Browse files
committed
print errors on failure
1 parent d696dbd commit b1ea18b

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

exe/arduino_ci_remote.rb

+17-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# terminate after printing any debug info. TODO: capture debug info
1010
def terminate
1111
puts "Failures: #{@failure_count}"
12+
unless failure_count.zero?
13+
puts "Last message: #{@arduino_cmd.last_msg}"
14+
puts "========== Stdout:"
15+
puts @arduino_cmd.last_out
16+
puts "========== Stderr:"
17+
puts @arduino_cmd.last_err
18+
end
1219
retcode = @failure_count.zero? ? 0 : 1
1320
exit(retcode)
1421
end
@@ -41,11 +48,11 @@ def assure(message, &block)
4148

4249
# initialize command and config
4350
config = ArduinoCI::CIConfig.default.from_project_library
44-
arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
51+
@arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
4552

4653
# initialize library under test
47-
installed_library_path = assure("Installing library under test") { arduino_cmd.install_local_library(".") }
48-
library_examples = arduino_cmd.library_examples(installed_library_path)
54+
installed_library_path = assure("Installing library under test") { @arduino_cmd.install_local_library(".") }
55+
library_examples = @arduino_cmd.library_examples(installed_library_path)
4956

5057
# gather up all required boards so we can install them up front.
5158
# start with the "platforms to unittest" and add the examples
@@ -64,34 +71,34 @@ def assure(message, &block)
6471
all_packages = all_platforms.values.map { |v| v[:package] }.uniq.reject(&:nil?)
6572
all_urls = all_packages.map { |p| config.package_url(p) }.uniq.reject(&:nil?)
6673
assure("Setting board manager URLs") do
67-
arduino_cmd.set_pref("boardsmanager.additional.urls", all_urls.join(","))
74+
@arduino_cmd.set_pref("boardsmanager.additional.urls", all_urls.join(","))
6875
end
6976

7077
all_packages.each do |p|
7178
assure("Installing board package #{p}") do
72-
arduino_cmd.install_boards(p)
79+
@arduino_cmd.install_boards(p)
7380
end
7481
end
7582

7683
aux_libraries.each do |l|
77-
assure("Installing aux library '#{l}'") { arduino_command.install_library(l) }
84+
assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
7885
end
7986

80-
attempt("Setting compiler warning level") { arduino_cmd.set_pref("compiler.warning_level", "all") }
87+
attempt("Setting compiler warning level") { @arduino_cmd.set_pref("compiler.warning_level", "all") }
8188

8289
library_examples.each do |example_path|
8390
ovr_config = config.from_example(example_path)
8491
ovr_config.platforms_to_build.each do |p|
8592
board = all_platforms[p][:board]
86-
assure("Switching to board for #{p} (#{board})") { arduino_cmd.use_board(board) }
93+
assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) }
8794
example_name = File.basename(example_path)
88-
attempt("Verifying #{example_name}") { arduino_cmd.verify_sketch(example_path) }
95+
attempt("Verifying #{example_name}") { @arduino_cmd.verify_sketch(example_path) }
8996
end
9097
end
9198

9299
config.platforms_to_unittest.each do |p|
93100
board = all_platforms[p][:board]
94-
assure("Switching to board for #{p} (#{board})") { arduino_cmd.use_board(board) }
101+
assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) }
95102
cpp_library.test_files.each do |unittest_path|
96103
unittest_name = File.basename(unittest_path)
97104
attempt("Unit testing #{unittest_name}") { cpp_library.test(unittest_path) }

spec/arduino_cmd_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ def get_sketch(dir, file)
77

88
RSpec.describe ArduinoCI::ArduinoCmd do
99
arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
10+
11+
after(:each) do |example|
12+
if example.exception
13+
puts "Last message: #{arduino_cmd.last_msg}"
14+
puts "========== Stdout:"
15+
puts arduino_cmd.last_out
16+
puts "========== Stderr:"
17+
puts arduino_cmd.last_err
18+
end
19+
end
20+
1021
context "initialize" do
1122
it "sets base vars" do
1223
expect(arduino_cmd.base_cmd).not_to be nil
@@ -28,6 +39,13 @@ def get_sketch(dir, file)
2839
end
2940
end
3041

42+
context "installation of boards" do
43+
it "installs and sets boards" do
44+
expect(arduino_cmd.install_boards("arduino:sam")).to be true
45+
expect(arduino_cmd.use_board("arduino:sam:arduino_due_x")).to be true
46+
end
47+
end
48+
3149
context "set_pref" do
3250

3351
it "Sets key to what it was before" do

0 commit comments

Comments
 (0)