Using ruby to test IronRuby
This is not pretty, but it’s a start. It started as a nobel goal of publishing an easy to read output of all the ruby tests here, but I’m not there yet, and really want to try to get a post up every weekday at least, so here’s what I’ve got so far.
I’m no ruby expert yet, but here is the script I wrote to run all the tests. It basically recursively searches all the paths below the “root” path for files named test_*, and then changes to that folder, and runs rbx filename, and appends the output to a text file. I’ve also thrown the text file up on the server here, although it desperately needs some formatting.
-
-
start_folder = ‘C:projectsIronRuby-Pre-Alpha1TestsRuby’
-
-
class TestRunner
-
-
def initialize
-
output_file_name = ‘c:IronRubyTests.log‘
-
@output_file = File.open(output_file_name, ‘w’)
-
end
-
-
def run_tests(folder, file)
-
puts ‘test ‘ + file
-
@output_file << ‘Running tests in ‘ + file
-
Dir.chdir(folder)
-
@output_file << `rbx #{file}`
-
end
-
-
def scan_folder(folder)
-
Dir.chdir(folder)
-
Dir.foreach(folder) do |f|
-
if f != "." and f != ".."
-
fullpath = folder + ” + f
-
run_tests(folder, f) if f =~ /test_*/
-
scan_folder(fullpath) if File.directory?(fullpath)
-
end
-
end
-
end
-
end
-
-
tester = TestRunner.new
-
tester.scan_folder(start_folder)
Please feel free to comment, I’m no ruby expert by any means yet, just hope to get there, and see IronRuby as a means to sneak it through IT, and hence learn it far more in depth. More on those devious little thoughts later
Although most of the tests in IronRuby are still erroring, or I’m not running them right, I’m still very optimistic.
Edit, thanks Dan!
Dan, who will quickly get sick of me asking him ruby questions, commented on Dir.glob. When you use the right tools, it’s amazing what you can get done.
-
-
start_folder = ‘C:/projects/IronRuby-Pre-Alpha1/Tests/Ruby’
-
@output_file = File.open(‘c:\tests.log‘, ‘w’)
-
-
def run_tests(file)
-
Dir.chdir(File.dirname(file))
-
puts ‘rbx #{File.basename(file)}’
-
@output_file << ‘Running tests in ‘ + file + "\r\n" + `rbx #{File.basename(file)}` + "\r\n"
-
end
-
-
Dir.glob("#{start_folder}/**/test_*.rb").each do |f|
-
run_tests(f)
-
end
-
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
September 1st, 2007 at 11:51 am
[…] it’s obvious the team has been busy. If you want to compare these to the last run the results are here, as well as the tiny script to run them […]