Skip to content

Commit

Permalink
Manual merge from HEAD.
Browse files Browse the repository at this point in the history
  • Loading branch information
bguthrie committed Sep 18, 2009
2 parents 9496fc0 + 989d6ba commit 59d5967
Show file tree
Hide file tree
Showing 36 changed files with 175 additions and 133 deletions.
2 changes: 1 addition & 1 deletion app/helpers/builds_helper.rb
Expand Up @@ -8,7 +8,7 @@ def select_builds(builds)
end
options.unshift "<option value=''>Older Builds...</option>"

select_tag "build", options, :onChange => "this.form.submit();"
select_tag "build", options.join, :onChange => "this.form.submit();"
end

def format_build_log(log)
Expand Down
4 changes: 2 additions & 2 deletions app/models/project.rb
Expand Up @@ -446,8 +446,8 @@ def do_clean_checkout(how_often = :always)

def do_clean_checkout?
case @clean_checkout_when
when :always: true
when nil, :never: false
when :always then true
when nil, :never then false
else
timestamp_filename = File.join(self.path, 'last_clean_checkout_timestamp')
unless File.exist?(timestamp_filename)
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CruiseControl.rb<%= @title ? " - " + @title : '' %></title>
Expand Down
10 changes: 7 additions & 3 deletions config/configuration.rb
Expand Up @@ -8,19 +8,19 @@ class Configuration
@email_from = 'cruisecontrol@thoughtworks.com'
@disable_build_now = false
@serialize_builds = false
@serialized_build_timeout = 1.hour
@serialized_build_timeout = 3.hour
@git_load_new_changesets_timeout = 5.minutes

class << self
# published configuration options (mentioned in config/site_config.rb.example)
attr_accessor :default_polling_interval, :disable_build_now, :email_from,
:dashboard_refresh_interval, :serialize_builds,
:serialized_build_timeout, :git_load_new_changesets_timeout
attr_writer :build_request_checking_interval
attr_reader :dashboard_url

# non-published configuration options (obscure stuff, mostly useful for http://cruisecontrolrb.thoughtworks.com)
attr_accessor :sleep_after_build_loop_error, :default_page
attr_accessor :default_page
attr_writer :build_request_checking_interval, :sleep_after_build_loop_error

def dashboard_url=(value)
@dashboard_url = remove_trailing_slash(value)
Expand All @@ -31,6 +31,10 @@ def projects_directory=(value)
"To configure this, set the CRUISE_DATA_ROOT environment variable"
end

def sleep_after_build_loop_error
@sleep_after_build_loop_error #.to_i
end

def build_request_checking_interval
@build_request_checking_interval.to_i
end
Expand Down
5 changes: 1 addition & 4 deletions config/environment.rb
Expand Up @@ -16,7 +16,7 @@
# Settings in config/environments/* take precedence over those specified here
config.gem "xml-simple", :lib => "xmlsimple"
config.gem "mocha"
config.gem "rcov"
config.gem "rcov" if RUBY_VERSION != '1.8.7' && RUBY_VERSION !~ /^1.9/

def find_home
looks_like_windows = (Config::CONFIG["target_os"] =~ /32/)
Expand Down Expand Up @@ -62,9 +62,6 @@ def find_home
require 'date'
require 'fileutils'

# custom MIME type for CCTray application
Mime::Type.register "application/cctray", :cctray

# get rid of cached pages between runs
FileUtils.rm_rf RAILS_ROOT + "/public/builds"
FileUtils.rm_rf RAILS_ROOT + "/public/documentation"
Expand Down
7 changes: 0 additions & 7 deletions config/initializers/fix_for_ruby_187.rb

This file was deleted.

3 changes: 3 additions & 0 deletions config/initializers/mime_types.rb
Expand Up @@ -3,3 +3,6 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

# custom MIME type for CCTray application
Mime::Type.register "application/cctray", :cctray
2 changes: 1 addition & 1 deletion cruise_config.rb
Expand Up @@ -3,5 +3,5 @@
# simple, ain't it

Project.configure do |project|
project.email_notifier.emails = ["cruisecontrolrb-developers@rubyforge.org"]
project.email_notifier.emails = ["cruisecontrolrb-developers@rubyforge.org"] if Socket.gethostname =~ /cruisecontrolrb.thoughtworks.com/
end
4 changes: 4 additions & 0 deletions daemon/cruise
Expand Up @@ -22,6 +22,10 @@
CRUISE_USER = ENV['CRUISE_USER'] || ENV['USER']
CRUISE_HOME = ENV['CRUISE_HOME'] || `pwd`.chomp

if !File.exist?(CRUISE_HOME + "/daemon/daemon_helper.rb")
raise "CRUISE_HOME was incorrectly set to '#{CRUISE_HOME}. Please hardcode it in this script, set it as an environment variable, or run this script as 'ci/cruise' from the ccrb project directory"
end

require CRUISE_HOME + "/daemon/daemon_helper"

command = ARGV.shift
Expand Down
13 changes: 7 additions & 6 deletions daemon/daemon_helper.rb
Expand Up @@ -12,9 +12,9 @@
require "rubygems"

begin
gem 'mongrel'
gem 'mongrel' if RUBY_VERSION =~ /^1.8/
rescue => e
puts "Error: daemon mode of CC.rb requires mongrel installed"
puts "Error: Under Ruby 1.8, daemon mode of CC.rb requires mongrel installed"
exit 1
end

Expand Down Expand Up @@ -62,7 +62,7 @@ def start(start_cmd)
# remove cruise pid file if process is no longer running
cruise_pid = read_cruise_pid
if cruise_pid
cruise_process = `ps -ea -o 'pid'`.grep(/#{cruise_pid}/).first
cruise_process = `ps -ea -o 'pid'`.split("\n").grep(/#{cruise_pid}/).first
FileUtils.rm(cruise_pid_file) unless cruise_process
end

Expand All @@ -86,7 +86,7 @@ def stop
print error_msg + "\n"
return 1
end
cruise_process = `ps -ea -o 'pid pgid command'`.grep(/^\s*#{cruise_pid}\s+\d+\s+.*/).first
cruise_process = `ps -ea -o 'pid pgid command'`.split("\n").grep(/^\s*#{cruise_pid}\s+\d+\s+.*/).first
cruise_process =~ /^\s*#{cruise_pid}\s+(\d+)\s+(.*)/
cruise_process_group = $1
cruise_process_command = $2
Expand All @@ -97,10 +97,11 @@ def stop
return 1
end

cruise_child_processes = `ps -ea -o 'pid pgid command'`.grep(/^\s*\d+\s+#{cruise_process_group}\s+/)
cruise_child_processes = `ps -ea -o 'pid pgid command'`.split("\n").grep(/^\s*\d+\s+#{cruise_process_group}\s+/)

print("Killing cruise process #{cruise_pid}: #{cruise_process_command}\n")
failed ||= !(system "mongrel_rails stop -P #{cruise_pid_file}")
server = RUBY_VERSION =~ /^1.9/ ? 'thin -f' : 'mongrel_rails'
failed ||= !(system "#{server} stop -P #{cruise_pid_file}")

cruise_child_processes.each do |child_process|
child_process =~ /^\s*(\d+)\s+#{cruise_process_group}\s+(.*)/
Expand Down
21 changes: 11 additions & 10 deletions db/migrate/002_move_custom_files_to_directory_in_user_home.rb
Expand Up @@ -2,28 +2,29 @@
include FileUtils

DATA_ROOT = ARGV[0]
RAILS_ROOT = File.expand_path(".")
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../..')
puts "RAILS_ROOT = #{RAILS_ROOT}"

if File.directory? 'projects'
mv 'projects', DATA_ROOT + '/projects'
if File.directory? RAILS_ROOT + '/projects'
mv RAILS_ROOT + '/projects', DATA_ROOT + '/projects'
else
mkdir_p DATA_ROOT + '/projects'
end

if File.exists? 'config/site_config.rb'
mv 'config/site_config.rb', DATA_ROOT + '/site_config.rb'
if File.exists? RAILS_ROOT + '/config/site_config.rb'
mv RAILS_ROOT + '/config/site_config.rb', DATA_ROOT + '/site_config.rb'
elsif !File.exists? DATA_ROOT + '/site_config.rb'
cp 'config/site_config.rb_example', DATA_ROOT + '/site_config.rb'
cp RAILS_ROOT + '/config/site_config.rb_example', DATA_ROOT + '/site_config.rb'
end

if File.exists? 'public/stylesheets/site.css'
mv 'public/stylesheets/site.css', DATA_ROOT + '/site.css'
if File.exists? RAILS_ROOT + '/public/stylesheets/site.css'
mv RAILS_ROOT + '/public/stylesheets/site.css', DATA_ROOT + '/site.css'
elsif !File.exists? DATA_ROOT + '/site.css'
cp 'public/stylesheets/site.css_example', DATA_ROOT + '/site.css'
cp RAILS_ROOT + '/public/stylesheets/site.css_example', DATA_ROOT + '/site.css'
end

mkdir_p DATA_ROOT + '/builder_plugins'
plugins = Dir['builder_plugins/**.rb']
plugins = Dir[RAILS_ROOT + '/builder_plugins/**.rb']
unless plugins.empty?
raise "We just created a data directory at #{DATA_ROOT}. Any builder plugins in addition to the ones in
#{RAILS_ROOT}/lib/builder_plugins need to be moved from
Expand Down
2 changes: 1 addition & 1 deletion lib/builder_plugins/builder_plugin.rb
Expand Up @@ -25,7 +25,7 @@ def initialize(project)

class << self
def known_event?(event_name)
self.instance_methods(false).include? event_name.to_s
self.instance_methods(false).map { |m| m.to_s }.include? event_name.to_s
end

def load_all
Expand Down
4 changes: 2 additions & 2 deletions lib/source_control/git.rb
Expand Up @@ -24,8 +24,8 @@ def checkout(revision = nil, stdout = $stdout)
# need to read from command output, because otherwise tests break
git('clone', [@repository, path], :execute_in_project_directory => false)

if @branch
git('branch', ['--track', @branch, "origin/#@branch"])
if @branch and @branch != 'master'
git('branch', ['--track', @branch, "origin/#{@branch}"])
git('checkout', ['-q', @branch]) # git prints 'Switched to branch "branch"' to stderr unless you pass -q
end
git("reset", ['--hard', revision.number]) if revision
Expand Down
3 changes: 2 additions & 1 deletion lib/source_control/subversion/propget_parser.rb
Expand Up @@ -3,6 +3,8 @@ class Subversion

class Subversion::PropgetParser
def parse(lines)
lines = lines.lines if lines.is_a?(String) && lines.respond_to?(:lines)

directories = {}
current_dir = nil
lines.each do |line|
Expand All @@ -20,4 +22,3 @@ def parse(lines)

end
end

6 changes: 4 additions & 2 deletions lib/tasks/cruise.rake
Expand Up @@ -16,10 +16,12 @@ task :cruise => ['geminstaller'] do
out = ENV['CC_BUILD_ARTIFACTS']
mkdir_p out unless File.directory? out if out

if RUBY_VERSION == '1.8.7'
puts '!!!!!! Skipping rcov on Ruby 1.8.7'
if RUBY_VERSION == '1.8.7' || RUBY_VERSION =~ /^1.9/
puts '!!!!!! Skipping rcov on Ruby 1.8.7 and 1.9'
Rake::Task["test:units"].invoke
Rake::Task["test:functionals"].invoke
# TODO: Why were there no integration tests under 1.8.7? Do they not work?
# Rake::Task["test:integration"].invoke
else
ENV['SHOW_ONLY'] = 'models,lib,helpers'
Rake::Task["test:units:rcov"].invoke
Expand Down
12 changes: 5 additions & 7 deletions lib/time_formatter.rb
Expand Up @@ -11,13 +11,11 @@ def human(time)
today = now.beginning_of_day
tomorrow = 1.day.since(today)

format =
case(time)
when Time.at(0)...this_year then '%d %b %y'
when this_year...today then '%d %b'
when today...tomorrow then '%H:%M'
else '%Y-%m-%d %H:%M:%S ?future?'
end
format = '%Y-%m-%d %H:%M:%S ?future?'
format = '%d %b %y' if time >= Time.at(0) && time < this_year
format = '%d %b' if time >= this_year && time < today
format = '%H:%M' if time >= today && time < tomorrow

remove_leading_zero(time.strftime(format))
end

Expand Down
2 changes: 1 addition & 1 deletion script/builder
Expand Up @@ -9,7 +9,7 @@ require 'optparse'
CRUISE_OPTIONS = { :verbose => false }

ARGV.options do |opts|
opts.banner = "Usage: cruise builder <project_name> []options]"
opts.banner = "Usage: cruise builder <project_name> [options]"

opts.separator ""

Expand Down
1 change: 0 additions & 1 deletion test/file_sandbox.rb
@@ -1,4 +1,3 @@
require 'ftools'
require 'fileutils'
require 'test/unit/assertions'

Expand Down
2 changes: 1 addition & 1 deletion test/functional/documentation_controller_test.rb
Expand Up @@ -14,7 +14,7 @@ def test_documentation
assert_response :success
assert_template 'documentation/docs'

assert_raises ActionView::MissingTemplate do
assert_raise ActionView::MissingTemplate do
get :get, :path => 'bad_request'
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/subversion_integration_test.rb
Expand Up @@ -16,7 +16,7 @@ def test_subversion_log_should_work_if_it_has_either_existing_path_or_repository

SourceControl::Subversion.new(:path => 'passing_project').latest_revision
SourceControl::Subversion.new(:path => 'foo', :repository => fixture_repository_url).latest_revision
assert_raises { Subversion.new(:path => 'foo').latest_revision }
assert_raise { Subversion.new(:path => 'foo').latest_revision }
end

def test_up_to_date
Expand Down
21 changes: 4 additions & 17 deletions test/test_helper.rb
Expand Up @@ -11,23 +11,10 @@
ActionMailer::Base.perform_deliveries = true

class Test::Unit::TestCase

def assert_raises(arg1 = nil, arg2 = nil)
expected_error = arg1.is_a?(Exception) ? arg1 : nil
expected_class = arg1.is_a?(Class) ? arg1 : nil
expected_message = arg1.is_a?(String) ? arg1 : arg2
begin
yield
fail "expected error was not raised"
rescue Test::Unit::AssertionFailedError
raise
rescue => e
raise if e.message == "expected error was not raised"
assert_equal(expected_error, e) if expected_error
assert_equal(expected_class, e.class, "Unexpected error type raised") if expected_class
assert_equal(expected_message, e.message, "Unexpected error message") if expected_message.is_a? String
assert_match(expected_message, e.message, "Unexpected error message") if expected_message.is_a? Regexp
end
def assert_raise_with_message(types, matcher, message = nil, &block)
args = [types].flatten + [message]
exception = assert_raise(*args, &block)
assert_match matcher, exception.message, message
end

def assert_false(expression)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/build_mailer_test.rb
Expand Up @@ -29,7 +29,7 @@ def test_test

private
def read_fixture(action)
IO.readlines("#{FIXTURES_PATH}/build_mailer/#{action}")
IO.readlines("#{FIXTURES_PATH}/build_mailer/#{action}").join
end

def encode(subject)
Expand Down
7 changes: 4 additions & 3 deletions test/unit/build_serializer_test.rb
Expand Up @@ -27,7 +27,7 @@ def test_serialize_handles_exceptions_in_block_passed_to_it
lock = AvailableLock.new
FileLock.expects(:new).returns(lock)

assert_raises "some exception" do
assert_raise_with_message(RuntimeError, "some exception") do
@serializer.serialize { raise "some exception" }
end

Expand Down Expand Up @@ -55,6 +55,7 @@ def lock.lock
end

def test_serialize_when_times_out
Configuration.stubs(:serialized_build_timeout).returns(5.hours)
lock = AvailableLock.new
Time.stubs(:now).returns(Time.at(0))
def @serializer.wait
Expand All @@ -66,13 +67,13 @@ def @serializer.wait
@project.expects(:notify).with(:queued).once
@project.expects(:notify).with(:timed_out).once
FileLock.expects(:new).returns(lock)
assert_raises "Timed out after waiting to build for about 1 hour" do
assert_raise_with_message(RuntimeError, "Timed out after waiting to build for about 5 hours") do
@serializer.serialize do
fail "should never run"
end
end

assert_equal Time.at(1.hour.to_i), Time.now
assert_equal Time.at(5.hours.to_i), Time.now
assert_false lock.locked?
end

Expand Down
4 changes: 2 additions & 2 deletions test/unit/build_status_test.rb
Expand Up @@ -97,7 +97,7 @@ def test_elapsed_time_should_return_elapsed_seconds_if_build_succeeded
end

def test_elapsed_time_should_raise_an_error_if_elapsed_time_not_availabe
assert_raises("Could not parse elapsed time") do
assert_raise_with_message(RuntimeError, "Could not parse elapsed time") do
BuildStatus.new("artifacts_directory").elapsed_time
end
end
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_status_should_be_incomplete_when_full_path_contains_dashes
private

def assert_exception_when_parsing_elapsed_time(file_name)
assert_raises("Could not parse elapsed time") do
assert_raise_with_message(RuntimeError, "Could not parse elapsed time") do
@status.match_elapsed_time(file_name)
end
end
Expand Down

0 comments on commit 59d5967

Please sign in to comment.