8000 Don't count false returns from inform blocks as failures · Arduino-CI/arduino_ci@ba104bc · GitHub
[go: up one dir, main page]

Skip to content

Commit ba104bc

Browse files
committed
Don't count false returns from inform blocks as failures
1 parent facd52a commit ba104bc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
### Fixed
1818
- Test file `int main(){}` needed a CPP extension in order to properly compile
1919
- Fixed build script reporting for `inform()` when it returns a non-string value from its block
20+
- Don't count false returns from `inform()` blocks as failures
2021

2122
### Security
2223

exe/arduino_ci_remote.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def terminate(final = nil)
2323
end
2424

2525
# make a nice status line for an action and react to the action
26-
def perform_action(message, multiline, mark_fn, on_fail_msg, abort_on_fail)
26+
def perform_action(message, multiline, mark_fn, on_fail_msg, tally_on_fail, abort_on_fail)
2727
line = "#{message}... "
2828
endline = "...#{message} "
2929
if multiline
@@ -39,7 +39,7 @@ def perform_action(message, multiline, mark_fn, on_fail_msg, abort_on_fail)
3939
puts mark.to_s.rjust(WIDTH - line.length, " ")
4040
unless result
4141
puts on_fail_msg unless on_fail_msg.nil?
42-
@failure_count += 1
42+
@failure_count += 1 if tally_on_fail
4343
# print out error messaging here if we've captured it
4444
terminate if abort_on_fail
4545
end
@@ -48,29 +48,30 @@ def perform_action(message, multiline, mark_fn, on_fail_msg, abort_on_fail)
4848

4949
# Make a nice status for something that defers any failure code until script exit
5050
def attempt(message, &block)
51-
perform_action(message, false, @passfail, nil, false, &block)
51+
perform_action(message, false, @passfail, nil, true, false, &block)
5252
end
5353

5454
# Make a nice status for something that defers any failure code until script exit
5555
def attempt_multiline(message, &block)
56-
perform_action(message, true, @passfail, nil, false, &block)
56+
perform_action(message, true, @passfail, nil, true, false, &block)
5757
end
5858

5959
# Make a nice status for something that kills the script immediately on failure
60+
FAILED_ASSURANCE_MESSAGE = "This may indicate a problem with ArduinoCI, or your configuration".freeze
6061
def assure(message, &block)
61-
perform_action(message, false, @passfail, "This may indicate a problem with ArduinoCI, or your configuration", true, &block)
62+
perform_action(message, false, @passfail, FAILED_ASSURANCE_MESSAGE, true, true, &block)
6263
end
6364

6465
def assure_multiline(message, &block)
65-
perform_action(message, true, @passfail, "This may indicate a problem with ArduinoCI, or your configuration", true, &block)
66+
perform_action(message, true, @passfail, FAILED_ASSURANCE_MESSAGE, true, true, &block)
6667
end
6768

6869
def inform(message, &block)
69-
perform_action(message, false, proc { |x| x }, nil, false, &block)
70+
perform_action(message, false, proc { |x| x }, nil, false, false, &block)
7071
end
7172

7273
def inform_multiline(message, &block)
73-
perform_action(message, true, nil, nil, false, &block)
74+
perform_action(message, true, nil, nil, false, false, &block)
7475
end
7576

7677
# Assure that a platform exists and return its definition

0 commit comments

Comments
 (0)
0