Permalink
Browse files

* Reworked the inner loop *again*. This time should be a bit faster a…

…nd a lot more accurate to the output.

* A couple of refactors
* Removed the interactive tests; these weren't working with certain versions of test/unit anyhow.
  • Loading branch information...
1 parent 72b0e13 commit 3650a1c665e4dd663767f372e8ae65af021d21bd Erik Hollensbe committed Jan 8, 2011
Showing with 24 additions and 34 deletions.
  1. +0 −6 gems/template.gemspec
  2. +23 −14 lib/rubygems/commands/test_command.rb
  3. +1 −14 test/helper.rb
View
@@ -22,11 +22,5 @@ Gem::Specification.new do |s|
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- else
- end
- else
end
end
-
@@ -192,46 +192,55 @@ def run_tests(spec, rake_path)
handles, _, _ = IO.select(current_handles, nil, nil, 0.1)
buf = ""
- handles.each do |io|
- begin
- io.readpartial(16384, buf)
- rescue EOFError
- buf += io.read rescue ""
- current_handles.reject! { |x| x == io }
- rescue IOError
- current_handles.reject! { |x| x == io }
- end
- end if handles
+ if handles
+ handles.compact.each do |io|
+ begin
+ res = io.readline
+
+ unless res
+ current_handles.reject! { |x| x == io }
+ next
+ end
+
+ buf += res
+ rescue EOFError
+ buf += io.read rescue ""
+ current_handles.reject! { |x| x == io }
+ end
+ end
+ end
[buf, current_handles]
end
outer_reader_proc = proc do |stdout, stderr|
loop do
- handles = [stdout, stderr]
+ handles = [stderr, stdout]
buf, handles = reader_proc.call(handles)
output += buf
print buf
break if handles.empty?
end
end
+ rake_args = [rake_path, 'test', '--trace']
+
# jruby stuffs it under IO, so we'll use that if it's available
klass =
if IO.respond_to?(:popen4)
- IO.popen4(rake_path, 'test', '--trace') do |pid, stdin, stdout, stderr|
+ IO.popen4(*rake_args) do |pid, stdin, stdout, stderr|
outer_reader_proc.call(stdout, stderr)
end
exit_status = $?
elsif RUBY_VERSION > '1.9'
require 'open3'
- exit_status = Open3.popen3(rake_path, 'test', '--trace') do |stdin, stdout, stderr, thr|
+ exit_status = Open3.popen3(*rake_args) do |stdin, stdout, stderr, thr|
outer_reader_proc.call(stdout, stderr)
thr.value
end
else
require 'open4-vendor'
- exit_status = Open4.popen4(rake_path, 'test', '--trace') do |pid, stdin, stdout, stderr|
+ exit_status = Open4.popen4(*rake_args) do |pid, stdin, stdout, stderr|
outer_reader_proc.call(stdout, stderr)
end
end
View
@@ -36,6 +36,7 @@ def template_gemspec(hash)
erb = ERB.new(File.read(File.join('gems', 'template.gemspec')))
@development_dependencies = ""
+
(hash[:development_dependencies] || []).each do |dep|
@development_dependencies += "s.add_development_dependency '#{dep}'\n"
end
@@ -58,17 +59,3 @@ def setup
set_configuration({ })
end
end
-
-class Test::Unit::TestCase::Interactive < Test::Unit::TestCase
- def setup
- super
-
- require 'rubygems/on_install_test'
- puts
- puts "----- This test is interactive -----"
- puts
- end
-
- def test_01_null
- end
-end

0 comments on commit 3650a1c

Please sign in to comment.