readall: fail on Ruby syntax warnings
Previously, syntax warnings were printed, but didn't cause `readall` to exit with a non-zero exit code. Now they do, making it easier to catch accidentally introduced syntax warnings in the test bot.
This commit is contained in:
parent
cbc24a715c
commit
a61829da46
@ -22,7 +22,8 @@ module Homebrew
|
||||
Thread.new do
|
||||
begin
|
||||
while rb = ruby_files.pop(true)
|
||||
failed = true unless system RUBY_PATH, "-c", "-w", rb
|
||||
# As a side effect, print syntax errors/warnings to `$stderr`.
|
||||
failed = true if syntax_errors_or_warnings?(rb)
|
||||
end
|
||||
rescue ThreadError # ignore empty queue error
|
||||
end
|
||||
@ -69,4 +70,17 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def syntax_errors_or_warnings?(rb)
|
||||
# Retrieve messages about syntax errors/warnings printed to `$stderr`, but
|
||||
# discard a `Syntax OK` printed to `$stdout` (in absence of syntax errors).
|
||||
messages = Utils.popen_read("#{RUBY_PATH} -c -w #{rb} 2>&1 >/dev/null")
|
||||
$stderr.print messages
|
||||
|
||||
# Only syntax errors result in a non-zero status code. To detect syntax
|
||||
# warnings we also need to inspect the output to `$stderr`.
|
||||
!$?.success? || !messages.chomp.empty?
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user