Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/util.rb view on Meta::CPAN
# successfully start svnserve on a free one.
@svnserve_ports.each do |port|
@svnserve_pid = fork {
STDERR.close
exec("svnserve",
"--listen-host", @svnserve_host,
"--listen-port", port,
"-d", "--foreground")
}
pid, status = Process.waitpid2(@svnserve_pid, Process::WNOHANG)
if status and status.exited?
if $DEBUG
STDERR.puts "port #{port} couldn't be used for svnserve"
end
else
# svnserve started successfully. Note port number and cease
# startup attempts.
@svnserve_port = port
@repos_svnserve_uri =
"svn://#{@svnserve_host}:#{@svnserve_port}#{@full_repos_path}"
# Avoid a race by waiting a short time for svnserve to start up.
# Without this, tests can fail with "Connection refused" errors.
sleep 1
break
end
end
if @svnserve_port.nil?
msg = "Can't run svnserve because available port "
msg << "isn't exist in [#{@svnserve_ports.join(', ')}]"
raise msg
end
end
def teardown_svnserve
if @svnserve_pid
Process.kill(:TERM, @svnserve_pid)
begin
Process.waitpid(@svnserve_pid)
rescue Errno::ECHILD
end
end
end
def add_pre_revprop_change_hook
File.open(@repos.pre_revprop_change_hook, "w") do |hook|
hook.print <<-HOOK
#!/bin/sh
REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
if [ "$PROPNAME" = "#{Svn::Core::PROP_REVISION_LOG}" -a \
"$USER" = "#{@author}" ]; then
exit 0
fi
exit 1
HOOK
end
FileUtils.chmod(0755, @repos.pre_revprop_change_hook)
end
end
module SetupEnvironment
def setup_test_environment(top_dir, base_dir, ext_dir)
svnserve_dir = File.join(top_dir, 'subversion', 'svnserve')
ENV["PATH"] = "#{svnserve_dir}:#{ENV['PATH']}"
FileUtils.ln_sf(File.join(base_dir, ".libs"), ext_dir)
end
end
if Svn::Util.windows?
require 'windows_util'
include Windows::Svnserve
extend Windows::SetupEnvironment
else
include Svnserve
extend SetupEnvironment
end
end
( run in 0.703 second using v1.01-cache-2.11-cpan-63c85eba8c4 )