Skip to content

Commit

Permalink
Run specs in verbose mode on Ruby 3+
Browse files Browse the repository at this point in the history
Fix verbose warning in spec.

Remove spec_*_w rake tasks

Limit use of warning gem to mysql/mysql2 adapters, as those
drivers still have taint warnings.
  • Loading branch information
jeremyevans committed Dec 15, 2021
1 parent 07d720f commit ce5b073
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 27 deletions.
12 changes: 1 addition & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ run_spec = proc do |file|
lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
rubylib = ENV['RUBYLIB']
ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
sh "#{FileUtils::RUBY} #{file}"
sh "#{FileUtils::RUBY} #{"-w" if RUBY_VERSION >= '3'} #{file}"
ENV['RUBYLIB'] = rubylib
end

Expand All @@ -80,16 +80,6 @@ spec_task = proc do |description, name, file, coverage, visibility|
run_spec.call(file)
end

desc "#{description} with warnings, some warnings filtered"
task :"#{name}_w" do
rubyopt = ENV['RUBYOPT']
ENV['RUBYOPT'] = "#{rubyopt} -w"
ENV['WARNING'] = '1'
run_spec.call(file)
ENV.delete('WARNING')
ENV['RUBYOPT'] = rubyopt
end

if coverage
desc "#{description} with coverage"
task :"#{name}_cov" do
Expand Down
2 changes: 1 addition & 1 deletion spec/adapters/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'logger'
require_relative "../sequel_warning"

if ENV['COVERAGE']
require_relative "../sequel_coverage"
Expand Down Expand Up @@ -33,6 +32,7 @@
DB = Sequel.connect(ENV[env_var])
end

require_relative "../sequel_warning"
require_relative "../visibility_checking" if ENV['CHECK_METHOD_VISIBILITY']

IDENTIFIER_MANGLING = !!ENV['SEQUEL_IDENTIFIER_MANGLING'] unless defined?(IDENTIFIER_MANGLING)
Expand Down
2 changes: 0 additions & 2 deletions spec/core/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_relative "../sequel_warning"

if ENV['COVERAGE']
require_relative "../sequel_coverage"
SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(\w+\.rb|(dataset|database|model|connection_pool)/\w+\.rb|adapters/mock\.rb)\z})
Expand Down
2 changes: 0 additions & 2 deletions spec/core_extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_relative "sequel_warning"

if ENV['COVERAGE']
require_relative "sequel_coverage"
SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/extensions/core_extensions\.rb\z})
Expand Down
2 changes: 0 additions & 2 deletions spec/extensions/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_relative "../sequel_warning"

if ENV['COVERAGE']
require_relative "../sequel_coverage"
SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(extensions|plugins)/\w+\.rb\z})
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/dataset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
end

it "should support iterating over large numbers of records with paged_each" do
v = (2..100).map{|i| wait{@ds.insert(:number=>i*10)}}
(2..100).map{|i| wait{@ds.insert(:number=>i*10)}}

[:offset, :filter].each do |strategy|
rows = []
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'logger'
require_relative "../sequel_warning"

if ENV['COVERAGE']
require_relative "../sequel_coverage"
Expand Down Expand Up @@ -31,6 +30,7 @@
require_relative '../guards_helper'

DB = Sequel.connect(ENV['SEQUEL_INTEGRATION_URL']) unless defined?(DB)
require_relative "../sequel_warning"

IDENTIFIER_MANGLING = !!ENV['SEQUEL_IDENTIFIER_MANGLING'] unless defined?(IDENTIFIER_MANGLING)
DB.extension(:identifier_mangling) if IDENTIFIER_MANGLING
Expand Down
2 changes: 0 additions & 2 deletions spec/model/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_relative "../sequel_warning"

$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
require_relative "../../lib/sequel"

Expand Down
13 changes: 8 additions & 5 deletions spec/sequel_warning.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
if ENV['WARNING']
require 'warning'
Warning.ignore(:missing_ivar, File.dirname(File.dirname(__FILE__)))
Warning.ignore(/gems\/(tzinfo|activesupport)-\d/)
Warning.dedup if Warning.respond_to?(:dedup)
if RUBY_VERSION >= '3' && [:mysql, :mysql2].include?(DB.adapter_scheme)
begin
require 'warning'
rescue LoadError
else
Warning.ignore(:taint)
Warning.dedup if Warning.respond_to?(:dedup)
end
end

0 comments on commit ce5b073

Please sign in to comment.