Skip to content

Commit a7b604c

Browse files
committed
Improve CI script logging format
1 parent d98ead9 commit a7b604c

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
- `CppLibrary` can now report `gcc_version`
1010

1111
### Changed
12+
- `arduino_ci_remote.rb` now formats tasks with multiple output lines more nicely
1213

1314
### Deprecated
1415

exe/arduino_ci_remote.rb

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ def terminate(final = nil)
2121
end
2222

2323
# make a nice status line for an action and react to the action
24-
def perform_action(message, on_fail_msg, abort_on_fail)
25-
line = "#{message}..."
26-
print line
24+
def perform_action(message, multiline, on_fail_msg, abort_on_fail)
25+
line = "#{message}... "
26+
endline = "...#{message} "
27+
if multiline
28+
puts line
29+
else
30+
print line
31+
end
2732
result = yield
2833
mark = result ? "✓" : "✗"
34+
# if multline, put checkmark at full width
35+
print endline if multiline
2936
puts mark.rjust(WIDTH - line.length, " ")
3037
unless result
3138
puts on_fail_msg unless on_fail_msg.nil?
@@ -38,12 +45,17 @@ def perform_action(message, on_fail_msg, abort_on_fail)
3845

3946
# Make a nice status for something that defers any failure code until script exit
4047
def attempt(message, &block)
41-
perform_action(message, nil, false, &block)
48+
perform_action(message, false, nil, false, &block)
49+
end
50+
51+
# Make a nice status for something that defers any failure code until script exit
52+
def attempt_multiline(message, &block)
53+
perform_action(message, true, nil, false, &block)
4254
end
4355

4456
# Make a nice status for something that kills the script immediately on failure
4557
def assure(message, &block)
46-
perform_action(message, "This may indicate a problem with ArduinoCI!", true, &block)
58+
perform_action(message, false, "This may indicate a problem with ArduinoCI!", true, &block)
4759
end
4860

4961
# initialize command and config
@@ -56,6 +68,14 @@ def assure(message, &block)
5668
cpp_library = ArduinoCI::CppLibrary.new(installed_library_path)
5769
attempt("Library installed at #{installed_library_path}") { true }
5870

71+
# check GCC
72+
attempt_multiline("Checking GCC version") do
73+
version = cpp_library.gcc_version
74+
next nil unless version
75+
puts version.split("\n").map { |l| " #{l}" }.join("\n")
76+
version
77+
end
78+
5979
# gather up all required boards so we can install them up front.
6080
# start with the "platforms to unittest" and add the examples
6181
# while we're doing that, get the aux libraries as well
@@ -101,7 +121,7 @@ def assure(message, &block)
101121
last_board = board
102122
cpp_library.test_files.each do |unittest_path|
103123
unittest_name = File.basename(unittest_path)
104-
attempt("Unit testing #{unittest_name}") do
124+
attempt_multiline("Unit testing #{unittest_name}") do
105125
exe = cpp_library.build_for_test_with_configuration(
106126
unittest_path,
107127
config.aux_libraries_for_unittest,

0 commit comments

Comments
 (0)