Update to ruby/mspec@1d8cf64
This commit is contained in:
parent
a82a24ed57
commit
d3da01cd11
@ -38,11 +38,6 @@ class MSpecMain < MSpecScript
|
|||||||
|
|
||||||
options.targets
|
options.targets
|
||||||
|
|
||||||
options.on("--warnings", "Don't suppress warnings") do
|
|
||||||
config[:flags] << '-w'
|
|
||||||
ENV['OUTPUT_WARNINGS'] = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
options.on("-j", "--multi", "Run multiple (possibly parallel) subprocesses") do
|
options.on("-j", "--multi", "Run multiple (possibly parallel) subprocesses") do
|
||||||
config[:multi] = true
|
config[:multi] = true
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ class IOStub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write(*str)
|
def write(*str)
|
||||||
self << str.join
|
self << str.join('')
|
||||||
end
|
end
|
||||||
|
|
||||||
def << str
|
def << str
|
||||||
@ -16,7 +16,7 @@ class IOStub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def print(*str)
|
def print(*str)
|
||||||
write(str.join + $\.to_s)
|
write(str.join('') + $\.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(name, *args, &block)
|
def method_missing(name, *args, &block)
|
||||||
|
@ -19,7 +19,6 @@ class ComplainMatcher
|
|||||||
@verbose = $VERBOSE
|
@verbose = $VERBOSE
|
||||||
err = IOStub.new
|
err = IOStub.new
|
||||||
|
|
||||||
Thread.current[:in_mspec_complain_matcher] = true
|
|
||||||
$stderr = err
|
$stderr = err
|
||||||
$VERBOSE = @options.key?(:verbose) ? @options[:verbose] : false
|
$VERBOSE = @options.key?(:verbose) ? @options[:verbose] : false
|
||||||
begin
|
begin
|
||||||
@ -27,7 +26,6 @@ class ComplainMatcher
|
|||||||
ensure
|
ensure
|
||||||
$VERBOSE = @verbose
|
$VERBOSE = @verbose
|
||||||
$stderr = @saved_err
|
$stderr = @saved_err
|
||||||
Thread.current[:in_mspec_complain_matcher] = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@warning = err.to_s
|
@warning = err.to_s
|
||||||
|
@ -396,7 +396,7 @@ module MSpec
|
|||||||
desc = tag.escape(tag.description)
|
desc = tag.escape(tag.description)
|
||||||
file = tags_file
|
file = tags_file
|
||||||
if File.exist? file
|
if File.exist? file
|
||||||
lines = IO.readlines(file)
|
lines = File.readlines(file)
|
||||||
File.open(file, "w:utf-8") do |f|
|
File.open(file, "w:utf-8") do |f|
|
||||||
lines.each do |line|
|
lines.each do |line|
|
||||||
line = line.chomp
|
line = line.chomp
|
||||||
|
@ -8,46 +8,3 @@ if Object.const_defined?(:Warning) and Warning.respond_to?(:[]=)
|
|||||||
Warning[:deprecated] = true
|
Warning[:deprecated] = true
|
||||||
Warning[:experimental] = false
|
Warning[:experimental] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if Object.const_defined?(:Warning) and Warning.respond_to?(:warn)
|
|
||||||
def Warning.warn(message, category: nil)
|
|
||||||
# Suppress any warning inside the method to prevent recursion
|
|
||||||
verbose = $VERBOSE
|
|
||||||
$VERBOSE = nil
|
|
||||||
|
|
||||||
if Thread.current[:in_mspec_complain_matcher]
|
|
||||||
return $stderr.write(message)
|
|
||||||
end
|
|
||||||
|
|
||||||
case message
|
|
||||||
# $VERBOSE = true warnings
|
|
||||||
when /(.+\.rb):(\d+):.+possibly useless use of (<|<=|==|>=|>) in void context/
|
|
||||||
# Make sure there is a .should otherwise it is missing
|
|
||||||
line_nb = Integer($2)
|
|
||||||
unless File.exist?($1) and /\.should(_not)? (<|<=|==|>=|>)/ === File.readlines($1)[line_nb-1]
|
|
||||||
$stderr.write message
|
|
||||||
end
|
|
||||||
when /possibly useless use of (\+|-) in void context/
|
|
||||||
when /assigned but unused variable/
|
|
||||||
when /method redefined/
|
|
||||||
when /previous definition of/
|
|
||||||
when /instance variable @.+ not initialized/
|
|
||||||
when /statement not reached/
|
|
||||||
when /shadowing outer local variable/
|
|
||||||
when /setting Encoding.default_(in|ex)ternal/
|
|
||||||
when /unknown (un)?pack directive/
|
|
||||||
when /(un)?trust(ed\?)? is deprecated/
|
|
||||||
when /\.exists\? is a deprecated name/
|
|
||||||
when /Float .+ out of range/
|
|
||||||
when /passing a block to String#(bytes|chars|codepoints|lines) is deprecated/
|
|
||||||
when /core\/string\/modulo_spec\.rb:\d+: warning: too many arguments for format string/
|
|
||||||
when /regexp\/shared\/new_ascii(_8bit)?\.rb:\d+: warning: Unknown escape .+ is ignored/
|
|
||||||
else
|
|
||||||
$stderr.write message
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
$VERBOSE = verbose
|
|
||||||
end
|
|
||||||
else
|
|
||||||
$VERBOSE = nil unless ENV['OUTPUT_WARNINGS']
|
|
||||||
end
|
|
||||||
|
@ -92,33 +92,6 @@ RSpec.describe MSpecMain, "#run" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe "The --warnings option" do
|
|
||||||
before :each do
|
|
||||||
@options, @config = new_option
|
|
||||||
allow(MSpecOptions).to receive(:new).and_return(@options)
|
|
||||||
@script = MSpecMain.new
|
|
||||||
allow(@script).to receive(:config).and_return(@config)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "is enabled by #options" do
|
|
||||||
allow(@options).to receive(:on)
|
|
||||||
expect(@options).to receive(:on).with("--warnings", an_instance_of(String))
|
|
||||||
@script.options
|
|
||||||
end
|
|
||||||
|
|
||||||
it "sets flags to -w" do
|
|
||||||
@config[:flags] = []
|
|
||||||
@script.options ["--warnings"]
|
|
||||||
expect(@config[:flags]).to include("-w")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "set OUTPUT_WARNINGS = '1' in the environment" do
|
|
||||||
ENV['OUTPUT_WARNINGS'] = '0'
|
|
||||||
@script.options ["--warnings"]
|
|
||||||
expect(ENV['OUTPUT_WARNINGS']).to eq('1')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.describe "The -j, --multi option" do
|
RSpec.describe "The -j, --multi option" do
|
||||||
before :each do
|
before :each do
|
||||||
@options, @config = new_option
|
@options, @config = new_option
|
||||||
|
Loading…
x
Reference in New Issue
Block a user