JonathanTron-specjour 0.2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ module Specjour
2
+ module SocketHelpers
3
+ def ip_from_hostname(hostname)
4
+ Socket.getaddrinfo(hostname, nil, Socket::AF_INET, Socket::SOCK_STREAM).first.fetch(3)
5
+ end
6
+
7
+ def hostname
8
+ @hostname ||= Socket.gethostname
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require 'specjour'
2
+
3
+ namespace :specjour do
4
+ task :dispatch, [:project_path] do |task, args|
5
+ args.with_defaults :project_path => Rake.original_dir
6
+ Specjour::Dispatcher.new(args.project_path).start
7
+ end
8
+
9
+ namespace :cucumber do
10
+ task :dispatch, [:project_path] do |task, args|
11
+ args.with_defaults :project_path => Rake.original_dir
12
+ Specjour::Cucumber::Dispatcher.new(args.project_path).start
13
+ end
14
+ end
15
+
16
+ desc "Dispatch the project to listening managers"
17
+ task :cucumber => "cucumber:dispatch"
18
+ end
19
+
20
+ desc "Dispatch the project to listening managers"
21
+ task :specjour => "specjour:dispatch"
@@ -0,0 +1 @@
1
+ load File.join(File.dirname(__FILE__), "dispatch.rake")
@@ -0,0 +1,86 @@
1
+ module Specjour
2
+ require 'specjour/cucumber'
3
+
4
+ class Worker
5
+ include Protocol
6
+ include SocketHelpers
7
+ attr_accessor :printer_uri
8
+ attr_reader :project_path, :specs_to_run, :number, :batch_size
9
+
10
+ def initialize(project_path, printer_uri, number, batch_size)
11
+ @project_path = project_path
12
+ @specs_to_run = specs_to_run
13
+ @number = number.to_i
14
+ @batch_size = batch_size.to_i
15
+ self.printer_uri = printer_uri
16
+ Rspec::DistributedFormatter.batch_size = batch_size
17
+ set_env_variables
18
+ end
19
+
20
+ def printer_uri=(val)
21
+ @printer_uri = URI.parse(val)
22
+ end
23
+
24
+ def run
25
+ run_time = 0
26
+ Dir.chdir(project_path)
27
+ while test = connection.next_test
28
+ run_time += Benchmark.realtime do
29
+ run_test test
30
+ end
31
+ end
32
+ connection.send_message(:worker_summary=, {:duration => sprintf("%6f", run_time)})
33
+ connection.send_message(:done)
34
+ connection.disconnect
35
+ end
36
+
37
+ protected
38
+
39
+ def connection
40
+ @connection ||= printer_connection
41
+ end
42
+
43
+ def printer_connection
44
+ Connection.new printer_uri
45
+ end
46
+
47
+ def run_test(test)
48
+ puts "[#{ENV['TEST_ENV_NUMBER']}] Running #{test}"
49
+ if test =~ /\.feature$/
50
+ run_feature test
51
+ else
52
+ run_spec test
53
+ end
54
+ end
55
+
56
+ def run_feature(feature)
57
+ set_up_cucumber
58
+ cli = ::Cucumber::Cli::Main.new(['--format', 'Specjour::Cucumber::DistributedFormatter', feature], connection)
59
+ cli.execute!(::Cucumber::Cli::Main.step_mother)
60
+ end
61
+
62
+ def run_spec(spec)
63
+ options = Spec::Runner::OptionParser.parse(
64
+ ['--format=Specjour::Rspec::DistributedFormatter', spec],
65
+ $stderr,
66
+ connection
67
+ )
68
+ Spec::Runner.use options
69
+ options.run_examples
70
+ end
71
+
72
+ def set_env_variables
73
+ ENV['PREPARE_DB'] = 'true'
74
+ ENV['RSPEC_COLOR'] = 'true'
75
+ ENV['TEST_ENV_NUMBER'] = number.to_s
76
+ end
77
+
78
+ def set_up_cucumber
79
+ unless @cucumber_loaded
80
+ Cucumber::DistributedFormatter.batch_size = batch_size
81
+ ::Cucumber::Cli::Options.class_eval { def print_profile_information; end }
82
+ @cucumber_loaded = true
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,6 @@
1
+ if ENV['PREPARE_DB']
2
+ Rails.configuration.after_initialize do
3
+ require 'specjour/db_scrub'
4
+ Specjour::DbScrub.scrub
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Specjour::CPU do
4
+ context "on a Mac" do
5
+ let(:hostinfo) do
6
+ %(
7
+ Mach kernel version:
8
+ Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386
9
+ Kernel configured for up to 2 processors.
10
+ 2 processors are physically available.
11
+ 220 processors are logically available.
12
+ Processor type: i486 (Intel 80486)
13
+ Processors active: 0 1
14
+ Primary memory available: 4.00 gigabytes
15
+ Default processor set: 72 tasks, 310 threads, 2 processors
16
+ Load average: 0.09, Mach factor: 1.90
17
+ )
18
+ end
19
+
20
+ before do
21
+ stub(Specjour::CPU).command.returns(hostinfo)
22
+ end
23
+
24
+ it "returns the number of logically available processors" do
25
+ Specjour::CPU.cores.should == 220
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ class CustomException < RuntimeError
4
+ end
5
+
6
+ def boo
7
+ raise CustomException, 'fails'
8
+ end
9
+
10
+ describe Specjour::Worker do
11
+ it "fails" do
12
+ boo
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Specjour::Manager do
4
+ describe "#available_for?" do
5
+ it "is available for all projects by default" do
6
+ subject.available_for?(rand.to_s).should be_true
7
+ end
8
+
9
+ it "is available for one project" do
10
+ manager = Specjour::Manager.new :registered_projects => %w(one)
11
+ manager.available_for?('one').should be_true
12
+ end
13
+
14
+ it "is available for many projects" do
15
+ manager = Specjour::Manager.new :registered_projects => %w(one two)
16
+ manager.available_for?('one').should be_true
17
+ manager.available_for?('two').should be_true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Specjour::RsyncDaemon do
4
+ subject do
5
+ Specjour::RsyncDaemon.new('/tmp/seasonal', 'seasonal')
6
+ end
7
+
8
+ before do
9
+ stub(Kernel).system
10
+ stub(Kernel).at_exit
11
+ stub(Dir).chdir
12
+ stub(File).open
13
+ stub(File).read
14
+ end
15
+
16
+ specify { subject.config_directory.should == '/tmp/seasonal/.specjour' }
17
+ specify { subject.config_file.should == '/tmp/seasonal/.specjour/rsyncd.conf' }
18
+
19
+ describe "#start" do
20
+ it "writes the config" do
21
+ mock(subject).write_config
22
+ subject.start
23
+ end
24
+
25
+ it "executes the system command in the project directory" do
26
+ mock(Kernel).system(*subject.send(:command))
27
+ mock(Dir).chdir(subject.project_path).yields
28
+ subject.start
29
+ end
30
+
31
+ it "stops at_exit" do
32
+ mock(subject).stop
33
+ mock.proxy(Kernel).at_exit.yields(subject)
34
+ subject.start
35
+ end
36
+ end
37
+
38
+ describe "#stop" do
39
+ context "with pid" do
40
+ before do
41
+ stub(subject).pid.returns(100_000_000)
42
+ stub(Process).kill
43
+ stub(FileUtils).rm
44
+ end
45
+
46
+ it "kills the pid with TERM" do
47
+ mock(Process).kill('TERM', subject.pid)
48
+ subject.stop
49
+ end
50
+
51
+ it "removes the pid file" do
52
+ mock(FileUtils).rm(subject.pid_file)
53
+ subject.stop
54
+ end
55
+ end
56
+
57
+ context "without pid" do
58
+ it "does nothing" do
59
+ stub(subject).pid
60
+ subject.stop.should be_nil
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "#check_config_version" do
66
+ it "warns when the version is out of date" do
67
+ stub(File).read { "# 0.0.0\n" }
68
+ mock($stderr).puts(/made changes/)
69
+ subject.send(:check_config_version)
70
+ end
71
+
72
+ it "doesn't warn when the version isn't out of date" do
73
+ stub(File).read { "# #{Specjour::RsyncDaemon::CONFIG_VERSION}\n" }
74
+ dont_allow($stderr).puts
75
+ subject.send(:check_config_version)
76
+ end
77
+ end
78
+
79
+ describe "#write_config" do
80
+ context "config exists" do
81
+ it "checks if the config is out of date" do
82
+ stub(File).exists?(anything) { true }
83
+ mock(subject).check_config_version
84
+ subject.send(:write_config)
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'specjour'
4
+ require 'spec/autorun'
5
+
6
+ Spec::Runner.configure do |config|
7
+ config.mock_with :rr
8
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Specjour do
4
+ it "lives"
5
+ end
@@ -0,0 +1,101 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{specjour}
8
+ s.version = "0.2.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Sandro Turriate"]
12
+ s.date = %q{2010-05-13}
13
+ s.default_executable = %q{specjour}
14
+ s.description = %q{Distribute your spec suite amongst your LAN via Bonjour.}
15
+ s.email = %q{sandro.turriate@gmail.com}
16
+ s.executables = ["specjour"]
17
+ s.extra_rdoc_files = [
18
+ "README.markdown"
19
+ ]
20
+ s.files = [
21
+ ".dev",
22
+ ".document",
23
+ ".gitignore",
24
+ "History.markdown",
25
+ "MIT_LICENSE",
26
+ "README.markdown",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/specjour",
30
+ "lib/specjour.rb",
31
+ "lib/specjour/connection.rb",
32
+ "lib/specjour/cpu.rb",
33
+ "lib/specjour/cucumber.rb",
34
+ "lib/specjour/cucumber/dispatcher.rb",
35
+ "lib/specjour/cucumber/distributed_formatter.rb",
36
+ "lib/specjour/cucumber/final_report.rb",
37
+ "lib/specjour/cucumber/printer.rb",
38
+ "lib/specjour/db_scrub.rb",
39
+ "lib/specjour/dispatcher.rb",
40
+ "lib/specjour/manager.rb",
41
+ "lib/specjour/printer.rb",
42
+ "lib/specjour/protocol.rb",
43
+ "lib/specjour/rspec.rb",
44
+ "lib/specjour/rspec/distributed_formatter.rb",
45
+ "lib/specjour/rspec/final_report.rb",
46
+ "lib/specjour/rspec/marshalable_rspec_failure.rb",
47
+ "lib/specjour/rsync_daemon.rb",
48
+ "lib/specjour/socket_helpers.rb",
49
+ "lib/specjour/tasks/dispatch.rake",
50
+ "lib/specjour/tasks/specjour.rb",
51
+ "lib/specjour/worker.rb",
52
+ "rails/init.rb",
53
+ "spec/cpu_spec.rb",
54
+ "spec/lib/specjour/worker_spec.rb",
55
+ "spec/manager_spec.rb",
56
+ "spec/rsync_daemon_spec.rb",
57
+ "spec/spec.opts",
58
+ "spec/spec_helper.rb",
59
+ "spec/specjour_spec.rb",
60
+ "specjour.gemspec"
61
+ ]
62
+ s.homepage = %q{http://github.com/sandro/specjour}
63
+ s.rdoc_options = ["--charset=UTF-8"]
64
+ s.require_paths = ["lib"]
65
+ s.rubygems_version = %q{1.3.6}
66
+ s.summary = %q{Distribute your spec suite amongst your LAN via Bonjour.}
67
+ s.test_files = [
68
+ "spec/cpu_spec.rb",
69
+ "spec/lib/specjour/worker_spec.rb",
70
+ "spec/manager_spec.rb",
71
+ "spec/rsync_daemon_spec.rb",
72
+ "spec/spec_helper.rb",
73
+ "spec/specjour_spec.rb"
74
+ ]
75
+
76
+ if s.respond_to? :specification_version then
77
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
78
+ s.specification_version = 3
79
+
80
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
81
+ s.add_runtime_dependency(%q<dnssd>, ["= 1.3.1"])
82
+ s.add_runtime_dependency(%q<rspec>, [">= 0"])
83
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
84
+ s.add_development_dependency(%q<rr>, ["= 0.10.11"])
85
+ s.add_development_dependency(%q<yard>, ["= 0.5.3"])
86
+ else
87
+ s.add_dependency(%q<dnssd>, ["= 1.3.1"])
88
+ s.add_dependency(%q<rspec>, [">= 0"])
89
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
90
+ s.add_dependency(%q<rr>, ["= 0.10.11"])
91
+ s.add_dependency(%q<yard>, ["= 0.5.3"])
92
+ end
93
+ else
94
+ s.add_dependency(%q<dnssd>, ["= 1.3.1"])
95
+ s.add_dependency(%q<rspec>, [">= 0"])
96
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
97
+ s.add_dependency(%q<rr>, ["= 0.10.11"])
98
+ s.add_dependency(%q<yard>, ["= 0.5.3"])
99
+ end
100
+ end
101
+
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: JonathanTron-specjour
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 5
9
+ - 1
10
+ version: 0.2.5.1
11
+ platform: ruby
12
+ authors:
13
+ - Sandro Turriate
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-15 00:00:00 +02:00
19
+ default_executable: specjour
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: dnssd
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 3
31
+ - 1
32
+ version: 1.3.1
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 1
56
+ - 3
57
+ - 0
58
+ version: 1.3.0
59
+ type: :development
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: rr
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ - 10
71
+ - 11
72
+ version: 0.10.11
73
+ type: :development
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: yard
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ - 5
85
+ - 3
86
+ version: 0.5.3
87
+ type: :development
88
+ version_requirements: *id005
89
+ description: Distribute your spec suite amongst your LAN via Bonjour.
90
+ email: sandro.turriate@gmail.com
91
+ executables:
92
+ - specjour
93
+ extensions: []
94
+
95
+ extra_rdoc_files:
96
+ - README.markdown
97
+ files:
98
+ - .dev
99
+ - .document
100
+ - .gitignore
101
+ - History.markdown
102
+ - JonathanTron-specjour.gemspec
103
+ - MIT_LICENSE
104
+ - README.markdown
105
+ - Rakefile
106
+ - VERSION
107
+ - bin/specjour
108
+ - lib/specjour.rb
109
+ - lib/specjour/connection.rb
110
+ - lib/specjour/cpu.rb
111
+ - lib/specjour/cucumber.rb
112
+ - lib/specjour/cucumber/dispatcher.rb
113
+ - lib/specjour/cucumber/distributed_formatter.rb
114
+ - lib/specjour/cucumber/final_report.rb
115
+ - lib/specjour/cucumber/printer.rb
116
+ - lib/specjour/db_scrub.rb
117
+ - lib/specjour/dispatcher.rb
118
+ - lib/specjour/manager.rb
119
+ - lib/specjour/printer.rb
120
+ - lib/specjour/protocol.rb
121
+ - lib/specjour/rspec.rb
122
+ - lib/specjour/rspec/distributed_formatter.rb
123
+ - lib/specjour/rspec/final_report.rb
124
+ - lib/specjour/rspec/marshalable_rspec_failure.rb
125
+ - lib/specjour/rsync_daemon.rb
126
+ - lib/specjour/socket_helpers.rb
127
+ - lib/specjour/tasks/dispatch.rake
128
+ - lib/specjour/tasks/specjour.rb
129
+ - lib/specjour/worker.rb
130
+ - rails/init.rb
131
+ - spec/cpu_spec.rb
132
+ - spec/lib/specjour/worker_spec.rb
133
+ - spec/manager_spec.rb
134
+ - spec/rsync_daemon_spec.rb
135
+ - spec/spec.opts
136
+ - spec/spec_helper.rb
137
+ - spec/specjour_spec.rb
138
+ - specjour.gemspec
139
+ has_rdoc: true
140
+ homepage: http://github.com/sandro/specjour
141
+ licenses: []
142
+
143
+ post_install_message:
144
+ rdoc_options:
145
+ - --charset=UTF-8
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ segments:
153
+ - 0
154
+ version: "0"
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
161
+ version: "0"
162
+ requirements: []
163
+
164
+ rubyforge_project:
165
+ rubygems_version: 1.3.6
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: Distribute your spec suite amongst your LAN via Bonjour.
169
+ test_files:
170
+ - spec/cpu_spec.rb
171
+ - spec/lib/specjour/worker_spec.rb
172
+ - spec/manager_spec.rb
173
+ - spec/rsync_daemon_spec.rb
174
+ - spec/spec_helper.rb
175
+ - spec/specjour_spec.rb