Permalink
Browse files

+ Added debug task to help isolate an error

[git-p4: depot-paths = "//src/ruby2ruby/dev/": change = 7394]
  • Loading branch information...
1 parent bc57cec commit ea2f7a626aba2eb422905ef4f1437d7a5894a1f1 @zenspider zenspider committed Apr 27, 2012
Showing with 41 additions and 10 deletions.
  1. +41 −10 Rakefile
View
@@ -19,31 +19,38 @@ Hoe.spec 'ruby2ruby' do
dependency "ruby_parser", "~> 2.0"
end
+def process ruby, file="stdin"
+ require "ruby_parser"
+ require "ruby2ruby"
+
+ parser = RubyParser.new
+ ruby2ruby = Ruby2Ruby.new
+
+ begin
+ sexp = parser.process(ruby, file)
+
+ ruby2ruby.process(sexp)
+ rescue Interrupt => e
+ raise e
+ end
+end
+
task :stress do
$: << "lib"
$: << "../../ruby_parser/dev/lib"
- require "ruby_parser"
- require "ruby2ruby"
require "pp"
files = Dir["../../*/dev/**/*.rb"]
warn "Stress testing against #{files.size} files"
- parser = RubyParser.new
- ruby2ruby = Ruby2Ruby.new
bad = {}
files.each do |file|
warn file
- ruby = File.read(file)
begin
- sexp = parser.process(ruby, file)
-
- # $stderr.puts sexp.pretty_inspect
-
- ruby2ruby.process(sexp)
+ process File.read(file), file
rescue Interrupt => e
raise e
rescue Exception => e
@@ -54,4 +61,28 @@ task :stress do
pp bad
end
+task :debug => :isolate do
+ ENV["V"] ||= "18"
+
+ $: << "lib"
+ require 'ruby_parser'
+
+ parser = if ENV["V"] == "18" then
+ Ruby18Parser.new
+ else
+ Ruby19Parser.new
+ end
+
+ file = ENV["F"] || ENV["FILE"]
+
+ ruby = if file then
+ File.read(file)
+ else
+ file = "env"
+ ENV["R"] || ENV["RUBY"]
+ end
+
+ puts process(ruby, file)
+end
+
# vim: syntax=ruby

0 comments on commit ea2f7a6

Please sign in to comment.