lib/testrbl.rb in testrbl-0.1.15 vs lib/testrbl.rb in testrbl-0.1.16
- old
+ new
@@ -17,17 +17,19 @@
INTERPOLATION = /\\\#\\\{.*?\\\}/
def self.run_from_cli(argv)
i_test, file, line = detect_usable(argv)
if file and line
- file = "./#{file}" if file =~ /^[a-z]/ # fix 1.9 not being able to load local files
+ file = localize(file)
run "#{ruby} #{i_test}#{file} -n '/#{pattern_from_file(File.readlines(file), line)}/'"
elsif file
run "#{ruby} #{i_test}#{file}"
+ elsif argv.all?{|f| File.file?(f) }
+ run "#{ruby} #{argv.map{|f| "-r #{localize(f)}" }.join(" ")} -e ''"
else # pass though
# no bundle exec: projects with mini and unit-test do not run well via bundle exec testrb
- run "testrb #{argv.map{|a| a.include?(' ') ? "'#{a}'" : a }.join(' ')}"
+ run ["testrb"] + argv
end
end
# useable e.g. via zeus
def self.pattern_from_file(lines, line)
@@ -53,10 +55,15 @@
raise "no test found before line #{line}"
end
private
+ # fix 1.9 not being able to load local files
+ def self.localize(file)
+ file =~ /^[-a-z\d_]/ ? "./#{file}" : file
+ end
+
def self.detect_usable(argv)
argv = argv.dup # do not mess up args
i_test = "-Itest " if ((argv.delete("-I") and argv.delete("test")) or argv.delete("-Itest"))
return unless argv.size == 1
@@ -75,12 +82,13 @@
"ruby"
end
end
def self.run(command)
- puts command
+ command = [*command]
+ puts command.join(" ")
STDOUT.flush # if exec fails horribly we at least see some output
- exec command
+ Kernel.exec *command
end
def self.pattern_from_line(line)
PATTERNS.each do |r|
next unless line =~ r