Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 11 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
View
2 .dev
@@ -1,3 +1,3 @@
export RUBYLIB=`pwd`/lib
-export RUBYOPT=rubygems
+export RUBYOPT="-r ubygems -r `pwd`/vendor/bundler/setup.rb"
export PATH=`pwd`/bin:$PATH
View
8 History.markdown
@@ -1,6 +1,14 @@
History
=======
+0.6.0 / 2012-07-19
+---------------------------
+* [fixed] First RSpec test to load would run twice
+* [added] Rsync options are now customizable via `Specjour::Configuration.rsync\_options=`
+ Useful when running on machines that use a combination of vendored gems and gemsets, i.e.
+ `-aL --delete --ignore-errors --exclude=vendor/ruby --exclude=.bundle`
+* [added] Benchmark times for various system status messages
+
0.5.6 / 2012-06-22
---------------------------
* [fixed] Specjour hang when attempting to resolve a bonjour reply
View
10 lib/specjour.rb
@@ -29,7 +29,7 @@ module Specjour
autoload :Cucumber, 'specjour/cucumber'
autoload :RSpec, 'specjour/rspec'
- VERSION ||= "0.5.6"
+ VERSION ||= "0.6.0"
HOOKS_PATH ||= "./.specjour/hooks.rb"
PROGRAM_NAME ||= $PROGRAM_NAME # keep a reference of the original program name
@@ -71,7 +71,7 @@ def self.log?
end
def self.load_custom_hooks
- require HOOKS_PATH if File.exists?(HOOKS_PATH)
+ load HOOKS_PATH if File.exists?(HOOKS_PATH)
end
def self.trap_interrupt
@@ -80,4 +80,10 @@ def self.trap_interrupt
abort("\n")
end
end
+
+ def self.benchmark(msg, &block)
+ print "#{msg}... "
+ time = Benchmark.realtime &block
+ puts "completed in #{time}s"
+ end
end
View
11 lib/specjour/configuration.rb
@@ -2,7 +2,7 @@ module Specjour
module Configuration
extend self
- attr_writer :before_fork, :after_fork, :after_load, :prepare
+ attr_writer :before_fork, :after_fork, :after_load, :prepare, :rsync_options
# This block is run by each worker before they begin running tests.
# The default action is to migrate the database, and clear it of any old
@@ -37,6 +37,11 @@ def reset
@after_fork = nil
@after_load = nil
@prepare = nil
+ @rsync_options = nil
+ end
+
+ def rsync_options
+ @rsync_options ||= default_rsync_options
end
def bundle_install
@@ -72,6 +77,10 @@ def default_prepare
end
end
+ def default_rsync_options
+ "-aL --delete --ignore-errors"
+ end
+
protected
def rails_with_ar?
View
4 lib/specjour/dispatcher.rb
@@ -47,7 +47,7 @@ def command_managers(&block)
end
def dispatcher_uri
- @dispatcher_uri ||= URI::Generic.build :scheme => "specjour", :host => hostname, :port => printer.port
+ @dispatcher_uri ||= URI::Generic.build :scheme => "specjour", :host => local_ip, :port => printer.port
end
def dispatch_work
@@ -111,7 +111,7 @@ def local_manager_needed?
end
def no_local_managers?
- managers.none? {|m| m.hostname == hostname}
+ managers.none? {|m| m.local_ip == local_ip}
end
def printer
View
2 lib/specjour/loader.rb
@@ -107,6 +107,8 @@ def filtered_examples
"#{e.file_path}:#{e.metadata[:line_number]}"
end
end.flatten.uniq
+ ensure
+ ::RSpec.reset
end
def kill_worker_processes
View
18 lib/specjour/manager.rb
@@ -22,6 +22,7 @@ def initialize(options = {})
@worker_task = options[:worker_task]
@registered_projects = options[:registered_projects]
@rsync_port = options[:rsync_port]
+ Specjour.load_custom_hooks
end
def available_for?(project_name)
@@ -109,8 +110,7 @@ def quiet?
end
def sync
- cmd "rsync -aL --delete --ignore-errors --port=#{rsync_port} #{dispatcher_uri.host}::#{project_name} #{project_path}"
- puts "rsync complete"
+ cmd "rsync #{Specjour::Configuration.rsync_options} --port=#{rsync_port} #{dispatcher_uri.host}::#{project_name} #{project_path}"
end
protected
@@ -131,14 +131,17 @@ def bonjour_service
end
def cmd(command)
- puts command
- system command
+ Specjour.benchmark(command) do
+ system *command.split
+ end
end
def execute_before_fork
- in_project do
- Specjour.load_custom_hooks
- Configuration.before_fork.call
+ Specjour.benchmark("before_fork") do
+ in_project do
+ Specjour.load_custom_hooks
+ Configuration.before_fork.call
+ end
end
end
@@ -166,5 +169,6 @@ def with_clean_env
yield
end
end
+
end
end
View
7 lib/specjour/rspec/preloader.rb
@@ -1,8 +1,9 @@
class Specjour::RSpec::Preloader
def self.load(paths=[])
- $stdout.puts "Loading RSpec Environment"
- require './spec/spec_helper'
- load_spec_files paths
+ Specjour.benchmark("Loading RSpec environment") do
+ require './spec/spec_helper'
+ load_spec_files paths
+ end
end
def self.load_spec_files(paths)
View
3 lib/specjour/rspec/runner.rb
@@ -1,5 +1,6 @@
module Specjour::RSpec::Runner
- ::RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE.replace "#{__FILE__}:#{__LINE__ + 3}:in `run'"
+ ::RSpec.configuration.backtrace_clean_patterns << %r(lib/specjour/)
+
def self.run(spec, output)
args = ['--format=Specjour::RSpec::DistributedFormatter', spec]
::RSpec::Core::Runner.run args, $stderr, output
View
4 lib/specjour/socket_helper.rb
@@ -12,6 +12,10 @@ def hostname
@hostname ||= Socket.gethostname
end
+ def local_ip
+ @local_ip ||= UDPSocket.open {|s| s.connect('74.125.224.103', 1); s.addr.last }
+ end
+
def current_uri
@current_uri ||= new_uri
end
View
14 spec/specjour/configuration_spec.rb
@@ -23,9 +23,6 @@ def self.version
end
describe Specjour::Configuration do
- subject do
- Specjour::Configuration
- end
before { subject.reset }
@@ -126,4 +123,15 @@ def self.version
end
end
end
+
+ describe "#rsync_options" do
+ it "allows custom rsync_options to be set" do
+ subject.rsync_options = '-a'
+ subject.rsync_options.should == '-a'
+ end
+
+ it "defaults to archive, symbolic links, delete, and ignore errors" do
+ subject.rsync_options.should == "-aL --delete --ignore-errors"
+ end
+ end
end
View
5 specjour.gemspec
@@ -29,7 +29,8 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('dnssd', ['= 2.0.0'])
s.add_runtime_dependency('thor', ['>= 0.14.0'])
s.add_development_dependency('rspec', ['>= 2.8.0'])
- s.add_development_dependency('rr', ['>= 1.0.4'])
+ s.add_development_dependency('rr')
s.add_development_dependency('cucumber', ['>= 1.1.4'])
- s.add_development_dependency('yard', ['>= 0.7.2'])
+ s.add_development_dependency('yard')
+ s.add_development_dependency('debugger')
end

No commit comments for this range

Something went wrong with that request. Please try again.