Revision: 1133 http://trac.macosforge.org/projects/ruby/changeset/1133 Author: eloy.de.enige@gmail.com Date: 2009-03-24 06:46:41 -0700 (Tue, 24 Mar 2009) Log Message: ----------- Added some MR workarounds to mspec in order to get tags to work. There are 2 problems: Dir[]/Dir.glob only return 1 entry. And File.read with a forced encoding does not work nor does String#encode work, this leads to very messed up Regexps if one does: Regexp.new Regexp.escape(str). Modified Paths: -------------- MacRuby/branches/experimental/mspec/lib/mspec/runner/filters/match.rb MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb Modified: MacRuby/branches/experimental/mspec/lib/mspec/runner/filters/match.rb =================================================================== --- MacRuby/branches/experimental/mspec/lib/mspec/runner/filters/match.rb 2009-03-24 13:46:26 UTC (rev 1132) +++ MacRuby/branches/experimental/mspec/lib/mspec/runner/filters/match.rb 2009-03-24 13:46:41 UTC (rev 1133) @@ -1,7 +1,11 @@ class MatchFilter def initialize(what, *strings) @what = what - @descriptions = to_regexp(*strings) + + # MR Hack: roxor does not work nicely with encodings yet, + # until it does let's assume that no regexps are used in the tags. + #@descriptions = to_regexp(*strings) + @descriptions = strings end def to_regexp(*strings) Modified: MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb =================================================================== --- MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb 2009-03-24 13:46:26 UTC (rev 1132) +++ MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb 2009-03-24 13:46:41 UTC (rev 1133) @@ -1,6 +1,14 @@ require 'mspec/guards/guard' require 'mspec/runner/formatters/dotted' +# MR Hack: Dir[]/Dir.glob only return the first entry, use ls in backticks. +# I know I feel dirty too ;) +class Dir + def self.[](pattern) + `ls #{pattern}`.split("\n") + end +end + # MSpecScript provides a skeleton for all the MSpec runner scripts. class MSpecScript @@ -169,16 +177,35 @@ patterns << File.join(config[:prefix], file) end + # patterns.each do |pattern| + # expanded = File.expand_path(pattern) + # return [pattern] if File.file?(expanded) + # + # specs = File.join(pattern, "/**/*_spec.rb") + # specs = File.expand_path(specs) rescue specs + # return Dir[specs].sort if File.directory?(expanded) + # end + # + # Dir[partial] + + # MR Hack: workaround return from block problem. + res = nil patterns.each do |pattern| expanded = File.expand_path(pattern) - return [pattern] if File.file?(expanded) - - specs = File.join(pattern, "/**/*_spec.rb") - specs = File.expand_path(specs) rescue specs - return Dir[specs].sort if File.directory?(expanded) + if File.file?(expanded) + res = [pattern] + elsif File.directory?(expanded) + # MR Hack: Atm we only really care about those in spec/frozen/language, + # and using backticks doesn't handle the same glob pattern. + #specs = File.join(pattern, "/**/*_spec.rb") + specs = File.join(pattern, "/*_spec.rb") + specs = File.expand_path(specs) rescue specs + res = Dir[specs].sort + end + break if res end - Dir[partial] + res || Dir[partial] end # Resolves each entry in +list+ to a set of files.
participants (1)
-
source_changes@macosforge.org