summaryrefslogtreecommitdiff
path: root/tool/test/webrick/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/test/webrick/utils.rb')
-rw-r--r--tool/test/webrick/utils.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/tool/test/webrick/utils.rb b/tool/test/webrick/utils.rb
index 56d3a30ea4..c8e84c37f1 100644
--- a/tool/test/webrick/utils.rb
+++ b/tool/test/webrick/utils.rb
@@ -38,6 +38,8 @@ module TestWEBrick
require "test/unit" unless defined?(Test::Unit)
include Test::Unit::Assertions
extend Test::Unit::Assertions
+ include Test::Unit::CoreAssertions
+ extend Test::Unit::CoreAssertions
module_function
@@ -79,4 +81,24 @@ module TestWEBrick
def start_httpproxy(config={}, log_tester=DefaultLogTester, &block)
start_server(WEBrick::HTTPProxyServer, config, log_tester, &block)
end
+
+ def start_cgi_server(config={}, log_tester=TestWEBrick::DefaultLogTester, &block)
+ config = {
+ :CGIInterpreter => TestWEBrick::RubyBin,
+ :DocumentRoot => File.dirname(__FILE__),
+ :DirectoryIndex => ["webrick.cgi"],
+ :RequestCallback => Proc.new{|req, res|
+ def req.meta_vars
+ meta = super
+ meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR)
+ meta[RbConfig::CONFIG['LIBPATHENV']] = ENV[RbConfig::CONFIG['LIBPATHENV']] if RbConfig::CONFIG['LIBPATHENV']
+ return meta
+ end
+ },
+ }.merge(config)
+ if RUBY_PLATFORM =~ /mswin|mingw|cygwin|bccwin32/
+ config[:CGIPathEnv] = ENV['PATH'] # runtime dll may not be in system dir.
+ end
+ start_server(WEBrick::HTTPServer, config, log_tester, &block)
+ end
end