Skip to content
Browse files

extract wait_for_child_process_to_exit for DRYer and more self-docume…

…nting tests of background rdoc generation
  • Loading branch information...
1 parent 55df43d commit bd15eefdd6166dc48a60c848ab7cf055a6a653b8 @alexch alexch committed Jul 7, 2012
View
8 lib/rubygems/test_case.rb
@@ -796,6 +796,14 @@ def nmake_found?
system('nmake /? 1>NUL 2>&1')
end
+ # In case we're building docs in a background process, this method waits for
+ # that process to exit (or if it's already been reaped, or never happened,
+ # swallows the Errno::ECHILD error).
+ def wait_for_child_process_to_exit
+ Process.wait if Process.respond_to?(:fork)
+ rescue Errno::ECHILD
+ end
+
##
# Allows tests to use a random (but controlled) port number instead of
# a hardcoded one. This helps CI tools when running parallels builds on
View
2 test/rubygems/test_gem_commands_install_command.rb
@@ -304,7 +304,7 @@ def test_execute_rdoc
assert_equal 0, e.exit_code
end
- Process.wait rescue Errno::ECHILD if Process.respond_to?(:fork)
+ wait_for_child_process_to_exit
assert_path_exists File.join(@a2.doc_dir, 'ri')
assert_path_exists File.join(@a2.doc_dir, 'rdoc')
View
2 test/rubygems/test_gem_commands_update_command.rb
@@ -274,7 +274,7 @@ def test_execute_rdoc
@cmd.execute
end
- Process.wait rescue Errno::ECHILD if Process.respond_to?(:fork)
+ wait_for_child_process_to_exit
assert_path_exists File.join(@a2.doc_dir, 'ri')
assert_path_exists File.join(@a2.doc_dir, 'rdoc')

0 comments on commit bd15eef

Please sign in to comment.
Something went wrong with that request. Please try again.