From 7aab983b8ed1050c4f3c4f545274db702e79ed97 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Thu, 3 Jan 2013 23:32:17 +0100 Subject: [PATCH] Do not try to load source of rbx precompiled libraries --- lib/mutant/matcher/method.rb | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/mutant/matcher/method.rb b/lib/mutant/matcher/method.rb index 2ffda2fe..90a1dd1e 100644 --- a/lib/mutant/matcher/method.rb +++ b/lib/mutant/matcher/method.rb @@ -16,6 +16,10 @@ module Mutant Classifier.run(input) end + # Methods within rbx kernel directory are precompiled and their source + # cannot be accessed via reading source location + BLACKLIST = %r(\Akernel/).freeze + # Enumerate matches # # @return [Enumerable] @@ -29,10 +33,7 @@ module Mutant def each(&block) return to_enum unless block_given? - unless source_location - $stderr.puts "#{method.inspect} does not have source location unable to emit matcher" - return self - end + return self if skip? subject.tap do |subject| yield subject if subject @@ -96,6 +97,26 @@ module Mutant public? end + # Test if method is skipped + # + # @return [true] + # true and print warning if location must be filtered + # + # @return [false] + # otherwise + # + # @api private + # + def skip? + location = source_location + if location.nil? or BLACKLIST.match(location.first) + $stderr.puts "#{method.inspect} does not have valid source location so mutant is unable to emit matcher" + return true + end + + false + end + # Return context # # @return [Context::Scope]