Skip to content

Commit

Permalink
make tests wait for docs to build in background (or force them to bui…
Browse files Browse the repository at this point in the history
…ld in foreground)
  • Loading branch information
alexch committed Jul 6, 2012
1 parent 322fac3 commit 55df43d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/rubygems/dependency_installer.rb
Expand Up @@ -32,6 +32,7 @@ class Gem::DependencyInstaller
:prerelease => false,
:security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
:wrappers => true,
:build_docs_in_background => true,
}.freeze

##
Expand Down Expand Up @@ -77,6 +78,7 @@ def initialize(options = {})
@security_policy = options[:security_policy]
@user_install = options[:user_install]
@wrappers = options[:wrappers]
@build_docs_in_background = options[:build_docs_in_background]

# Indicates that we should not try to update any deps unless
# we absolutely must.
Expand Down Expand Up @@ -378,14 +380,14 @@ def install dep_or_name, version = Gem::Requirement.default
hook.call self, @installed_gems
end
finish = Time.now
puts "Done installing documentation for #{@installed_gems.map(&:name).join(', ')} (#{(finish-start).to_i} sec)."
say "Done installing documentation for #{@installed_gems.map(&:name).join(', ')} (#{(finish-start).to_i} sec)."
end unless Gem.done_installing_hooks.empty?

@installed_gems
end

def in_background what
if Process.respond_to?(:fork)
if @build_docs_in_background and Process.respond_to?(:fork)
say "#{what} in a background process."
Process.fork do
yield
Expand Down
2 changes: 2 additions & 0 deletions test/rubygems/test_gem_commands_install_command.rb
Expand Up @@ -304,6 +304,8 @@ def test_execute_rdoc
assert_equal 0, e.exit_code
end

Process.wait rescue Errno::ECHILD if Process.respond_to?(:fork)

assert_path_exists File.join(@a2.doc_dir, 'ri')
assert_path_exists File.join(@a2.doc_dir, 'rdoc')
end
Expand Down
2 changes: 2 additions & 0 deletions test/rubygems/test_gem_commands_update_command.rb
Expand Up @@ -274,6 +274,8 @@ def test_execute_rdoc
@cmd.execute
end

Process.wait rescue Errno::ECHILD if Process.respond_to?(:fork)

assert_path_exists File.join(@a2.doc_dir, 'ri')
assert_path_exists File.join(@a2.doc_dir, 'rdoc')
end
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_dependency_installer.rb
Expand Up @@ -187,7 +187,7 @@ def test_install_dependency
FileUtils.mv @b1_gem, @tempdir

Dir.chdir @tempdir do
inst = Gem::DependencyInstaller.new
inst = Gem::DependencyInstaller.new(:build_docs_in_background => false)
inst.install 'b'
end

Expand Down

0 comments on commit 55df43d

Please sign in to comment.