From 9b9eb640f86a4d3994609a86af5063465961f9ad Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 23 Dec 2010 11:29:39 -0500 Subject: [PATCH] Added cruise task --- Rakefile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Rakefile b/Rakefile index e42cd8c..a85b478 100644 --- a/Rakefile +++ b/Rakefile @@ -57,6 +57,28 @@ module Koans end end +module RubyImpls + # Calculate the list of relevant Ruby implementations. + def self.find_ruby_impls + rubys = `rvm list`.gsub(/=>/,'').split(/\n/).sort + expected.map { |impl| + puts "DBG: impl=#{impl.inspect}" + last = rubys.grep(Regexp.new(Regexp.quote(impl))).last + last ? last.split.first : nil + }.compact + end + + # Return a (cached) list of relevant Ruby implementations. + def self.list + @list ||= find_ruby_impls + end + + # List of expected ruby implementations. + def self.expected + %w(ruby-1.8.6 ruby-1.8.7 ruby-1.9.2 jruby ree) + end +end + task :default => :walk_the_path task :walk_the_path do @@ -107,3 +129,38 @@ SRC_FILES.each do |koan_src| Koans.make_koan_file koan_src, t.name end end + +task :run do + puts 'koans' + Dir.chdir("src") do + puts "in #{Dir.pwd}" + sh "ruby path_to_enlightenment.rb" + end +end + + +desc "Pre-checkin tests (=> run_all)" +task :cruise => :run_all + +desc "Run the completed koans againts a list of relevant Ruby Implementations" +task :run_all do + results = {} + RubyImpls.list.each do |impl| + puts "=" * 40 + puts "On Ruby #{impl}" + res = sh "rvm #{impl} rake run" + results[impl] = res + puts + end + puts "=" * 40 + puts "Summary:" + puts + results.each do |impl, res| + puts "#{impl} => RAN" + end + puts + RubyImpls.expected.each do |requested_impl| + impl_pattern = Regexp.new(Regexp.quote(requested_impl)) + puts "No Results for #{requested_impl}" if results.keys.grep(impl_pattern).empty? + end +end