diff options
author | mneumann <mneumann@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-16 14:07:15 +0000 |
---|---|---|
committer | mneumann <mneumann@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-16 14:07:15 +0000 |
commit | 89f8c536896040e4f95957ed1e98d9a88898f89a (patch) | |
tree | bae2cbf373eb0d45800f0f8aad6b41006aa16d96 /test/xmlrpc/webrick_testing.rb | |
parent | 0a933d91fa562eddcc50e332e9742839f28b6a8f (diff) | |
download | ruby-89f8c536896040e4f95957ed1e98d9a88898f89a.tar.gz ruby-89f8c536896040e4f95957ed1e98d9a88898f89a.tar.xz ruby-89f8c536896040e4f95957ed1e98d9a88898f89a.zip |
added new test case (which spawn off a webrick XML-RPC server)
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/xmlrpc/webrick_testing.rb')
-rw-r--r-- | test/xmlrpc/webrick_testing.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/xmlrpc/webrick_testing.rb b/test/xmlrpc/webrick_testing.rb new file mode 100644 index 000000000..d8b3a864c --- /dev/null +++ b/test/xmlrpc/webrick_testing.rb @@ -0,0 +1,37 @@ +require 'timeout' + +module WEBrick_Testing + class DummyLog < WEBrick::BasicLog + def initialize() super(self) end + def <<(*args) end + end + + def start_server(config={}) + raise "already started" if @__server_pid or @__started + trap('HUP') { @__started = true } + @__server_pid = fork do + w = WEBrick::HTTPServer.new( + { + :Logger => DummyLog.new, + :AccessLog => [], + :StartCallback => proc { Process.kill('HUP', Process.ppid) } + }.update(config)) + yield w + trap('INT') { w.shutdown } + w.start + exit + end + + Timeout.timeout(5) { + nil until @__started # wait until the server is ready + } + end + + def stop_server + Process.kill('INT', @__server_pid) + @__server_pid = nil + @__started = false + Process.wait + raise unless $?.success? + end +end |