Issue #6573 has been updated by mlartz (Michael Artz).


It appears that WEBrick::HTTPServlet::CGIHandler (webrick/httpservlet/cgihandler.rb) file embeds RbConfig.ruby into a constant when the file is required.  test/ruby/envutil.rb monkeypatches RbConfig.ruby to use the newly compiled Ruby.  If, however, webrick gets 'require'd before test/ruby/envutil, then the internal CGIHandler constant has already been set.

So there is a simple fix, but I'm not sure if its the right one (although it feels right).  Put the following line into test/runner.rb:

require_relative 'ruby/envutil'

which should setup the environment for all the tests, which is what I think we want.

The not-so-simple solution is to find the offending webrick-requiring test and update it to require ruby/envutil before it requires webrick.  This seems like unnecessary work, assuming that the previous solution is sufficient.

I'm not in a place where I can provide a patch at the moment, so I'm hoping that someone else can finalize this.
----------------------------------------
Bug #6573: Webrick test failures
https://bugs.ruby-lang.org/issues/6573#change-27341

Author: bkabrda (Bohuslav Kabrda)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 1.9.3
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


Hi,
I'm randomly getting test failures for WEBrick with Ruby 1.9.3. The problem seems to be that WEBrick hangs during some test suite executions (I think it may be improperly shut down after previous tests). These are the failures I'm getting (running Fedora 17 x86_64):


50) Failure:
test_cgi(TestWEBrickCGI) [/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/test_cgi.rb:34]:
webrick log start:
  [2012-06-11 10:06:35] INFO  WEBrick 1.3.1
  [2012-06-11 10:06:35] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
  [2012-06-11 10:06:35] INFO  WEBrick::HTTPServer#start: pid=15944 port=40082
  [2012-06-11 10:06:35] ERROR CGIHandler: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi exit with 127
  [2012-06-11 10:06:35] ERROR Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi
  
webrick log end.
<"/webrick.cgi"> expected but was
<"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n<HTML>\n  <HEAD><TITLE>Internal Server Error</TITLE></HEAD>\n  <BODY>\n    <H1>Internal Server Error</H1>\n    Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi\n    <HR>\n    <ADDRESS>\n     WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20) OpenSSL/1.0.1c at\n     127.0.0.1:40082\n    </ADDRESS>\n  </BODY>\n</HTML>\n">.
 51) Failure:
test_script_disclosure(WEBrick::TestFileHandler) [/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/test_filehandler.rb:265]:
webrick log start:
  [2012-06-11 10:06:49] INFO  WEBrick 1.3.1
  [2012-06-11 10:06:49] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
  [2012-06-11 10:06:49] INFO  WEBrick::HTTPServer#start: pid=15944 port=34515
  [2012-06-11 10:06:49] ERROR CGIHandler: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi exit with 127
  [2012-06-11 10:06:49] ERROR Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi
webrick log end.
<"200"> expected but was
<"500">.

Here is the full build log from Fedora's Koji: http://koji.fedoraproject.org/koji/getfile?taskID=4148723&name=build.log

Is anyone experiencing the same failures
Thanks!


-- 
http://bugs.ruby-lang.org/