Skip to content

Commit bac43af

Browse files
committed
Merge pull request #1175 from bf4/quiet_success_messages
Disable coverage/warnings output when passing in dev
2 parents 8f2dd66 + 0e433d3 commit bac43af

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

.simplecov

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,32 @@ Coverage.start
4949

5050
## ADD SOME CUSTOM REPORTING AT EXIT
5151
SimpleCov.at_exit do
52+
next if $! and not ($!.kind_of? SystemExit and $!.success?)
53+
5254
header = "#{'*' * 20} SimpleCov Results #{'*' * 20}"
53-
@output.puts
54-
@output.puts header
55-
@output.puts SimpleCov.result.format!
55+
results = SimpleCov.result.format!.join("\n")
56+
exit_message = <<-EOF
57+
58+
#{header}
59+
{{RESULTS}}
60+
{{FAILURE_MESSAGE}}
61+
62+
#{'*' * header.size}
63+
EOF
5664
percent = Float(SimpleCov.result.covered_percent)
5765
if percent < @minimum_coverage
58-
@output.puts "Spec coverage was not high enough: "\
59-
"#{percent.round(2)} is < #{@minimum_coverage}%\n"
60-
exit 1 if @generate_report
61-
else
62-
@output.puts "Nice job! Spec coverage (#{percent.round(2)}) "\
63-
"is still at or above #{@minimum_coverage}%\n"
66+
failure_message = <<-EOF
67+
Spec coverage was not high enough: #{percent.round(2)}% is < #{@minimum_coverage}%
68+
EOF
69+
exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', failure_message)
70+
@output.puts exit_message
71+
abort(failure_message) if @generate_report
72+
elsif @running_ci
73+
exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', <<-EOF)
74+
Nice job! Spec coverage (#{percent.round(2)}%) is still at or above #{@minimum_coverage}%
75+
EOF
76+
@output.puts exit_message
6477
end
65-
@output.puts
66-
@output.puts '*' * header.size
6778
end
6879

6980
## CAPTURE CONFIG IN CLOSURE 'AppCoverage.start'

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ rvm:
1010
- 2.0.0
1111
- 2.1
1212
- 2.2
13-
- jruby-19mode
14-
- rbx-2
1513
- ruby-head
14+
- rbx-2
1615

1716
install:
1817
- bundle install --retry=3
1918

2019
script:
21-
- bundle exec rake
20+
- env CAPTURE_STDERR=false bundle exec rake
2221
- bundle exec rake rubocop
2322

2423
env:
@@ -28,6 +27,9 @@ env:
2827
- "RAILS_VERSION=master"
2928

3029
matrix:
30+
include:
31+
- rvm: jruby-19mode
32+
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false -Xcli.debug=true --debug'
3133
allow_failures:
3234
- rvm: ruby-head
3335
- env: "RAILS_VERSION=master"

test/capture_warnings.rb

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,44 @@ def execute!
2626
end
2727
end
2828

29-
# rubocop:disable Metrics/AbcSize
3029
def after_tests(lines)
3130
app_warnings, other_warnings = lines.partition do |line|
3231
line.include?(app_root) && !line.include?(bundle_dir)
3332
end
3433

35-
header = "#{'-' * 22} app warnings: #{'-' * 22}"
36-
output.puts
37-
output.puts header
38-
3934
if app_warnings.any?
40-
output.puts app_warnings.join("\n")
35+
warnings_message = app_warnings.join("\n")
36+
print_warnings = true
4137
else
42-
output.puts 'None. Yay!'
38+
warnings_message = 'None. Yay!'
39+
ENV['FULL_BUILD'] ||= ENV['CI']
40+
running_ci = ENV['FULL_BUILD'] =~ /\Atrue\z/i
41+
print_warnings = running_ci
4342
end
4443

4544
if other_warnings.any?
4645
File.write(File.join(output_dir, 'warnings.txt'), other_warnings.join("\n") << "\n")
47-
output.puts
48-
output.puts 'Non-app warnings written to tmp/warnings.txt'
49-
output.puts
46+
warnings_message << "\nNon-app warnings written to tmp/warnings.txt"
47+
print_warnings = true
5048
end
5149

52-
output.puts
53-
output.puts '-' * header.size
50+
header = "#{'-' * 22} app warnings: #{'-' * 22}"
51+
message = <<-EOF.strip_heredoc
52+
53+
#{header}
54+
55+
#{warnings_message}
56+
57+
#{'-' * header.size}
58+
EOF
59+
60+
output.puts(message) if print_warnings
5461

5562
# fail the build...
5663
if fail_on_warnings && app_warnings.any?
5764
abort "Failing build due to app warnings: #{app_warnings.inspect}"
5865
end
5966
end
60-
# rubocop:enable Metrics/AbcSize
6167

6268
private
6369

0 commit comments

Comments
 (0)