From 38a8f7f8ba22ee03bf5320921775e76c071d460e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 7 Dec 2011 17:32:01 -0800 Subject: speeding up ignored sql testing --- activerecord/test/cases/helper.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases/helper.rb') diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 6735bc521b..c62a172a1c 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -65,6 +65,9 @@ module ActiveRecord # ignored SQL. This ignored SQL is for Oracle. ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im] + cattr_accessor :ignored_sql_regexp + self.ignored_sql_regexp = Regexp.union ignored_sql + cattr_accessor :log self.log = [] @@ -74,7 +77,7 @@ module ActiveRecord # FIXME: this seems bad. we should probably have a better way to indicate # the query was cached unless 'CACHE' == values[:name] - self.class.log << sql unless self.class.ignored_sql.any? { |r| sql =~ r } + self.class.log << sql unless self.class.ignored_sql_regexp =~ sql end end end -- cgit v1.2.3 From a505b1377422a1821798d060301c50abea6afbd4 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 7 Dec 2011 17:42:05 -0800 Subject: moving ignored regexp to the instance --- activerecord/test/cases/helper.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'activerecord/test/cases/helper.rb') diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index c62a172a1c..b750a03fba 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -65,20 +65,22 @@ module ActiveRecord # ignored SQL. This ignored SQL is for Oracle. ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im] - cattr_accessor :ignored_sql_regexp - self.ignored_sql_regexp = Regexp.union ignored_sql - cattr_accessor :log self.log = [] + attr_reader :ignore + + def initialize(ignore = Regexp.union(self.class.ignored_sql)) + @ignore = ignore + end + def call(name, start, finish, message_id, values) sql = values[:sql] # FIXME: this seems bad. we should probably have a better way to indicate # the query was cached - unless 'CACHE' == values[:name] - self.class.log << sql unless self.class.ignored_sql_regexp =~ sql - end + return if 'CACHE' == values[:name] || ignore =~ sql + self.class.log << sql end end -- cgit v1.2.3 From d80e4ee20e690dfc0f4ec31c41b873d607462872 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 8 Dec 2011 10:17:37 -0800 Subject: Regexp.union seems to have different results in 1.8 --- activerecord/test/cases/helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/test/cases/helper.rb') diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index b750a03fba..ae2c230d15 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -70,8 +70,8 @@ module ActiveRecord attr_reader :ignore - def initialize(ignore = Regexp.union(self.class.ignored_sql)) - @ignore = ignore + def initialize(ignore = self.class.ignored_sql) + @ignore = ignore end def call(name, start, finish, message_id, values) @@ -79,7 +79,7 @@ module ActiveRecord # FIXME: this seems bad. we should probably have a better way to indicate # the query was cached - return if 'CACHE' == values[:name] || ignore =~ sql + return if 'CACHE' == values[:name] || ignore.any? { |x| x =~ sql } self.class.log << sql end end -- cgit v1.2.3 From bb106e9aa278a44cd970a3b820af1664fd85bba1 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 19 Dec 2011 21:05:28 -0800 Subject: remove more uses of deprecated logger methods --- activerecord/test/cases/helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases/helper.rb') diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index ae2c230d15..859c3d1947 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -8,6 +8,7 @@ require 'mocha' require 'active_record' require 'active_support/dependencies' +require 'active_support/logger' require 'support/config' require 'support/connection' @@ -90,7 +91,10 @@ end unless ENV['FIXTURE_DEBUG'] module ActiveRecord::TestFixtures::ClassMethods def try_to_load_dependency_with_silence(*args) - ActiveRecord::Base.logger.silence { try_to_load_dependency_without_silence(*args)} + old = ActiveRecord::Base.logger.level + ActiveRecord::Base.logger.level = ActiveSupport::Logger::ERROR + try_to_load_dependency_without_silence(*args) + ActiveRecord::Base.logger.level = old end alias_method_chain :try_to_load_dependency, :silence -- cgit v1.2.3