distributest 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ begin
2
+ require 'rubygems'
3
+ require 'erlectricity'
4
+ require 'distributest/test_runner'
5
+ require 'stringio'
6
+ #TODO Figure out a better way to get this to the user
7
+ rescue LoadError => e
8
+ puts "LOAD ERROR #{e.to_s}"
9
+ end
10
+
11
+ module Distributest
12
+ def self.start(runner_identifier, options = {})
13
+ ENV["DB_PREFIX"] = runner_identifier
14
+ start_loop
15
+ end
16
+
17
+ def self.start_loop
18
+ receive do |f|
19
+ f.when([:file, String]) do |text|
20
+ begin
21
+ pass_results, fail_results, profile, total_time_for_file, captured_std_err_out = Distributest::TestRunner.new.run_rspec_file(text)
22
+ rescue LoadError => e
23
+ f.send!([:load_error, e.to_s])
24
+ end
25
+ pass_results = pass_results.to_s
26
+ #Basically letting master know it ran a file even though it didn't have runnable specs
27
+ if (pass_results.nil? || pass_results.length == 0) && (fail_results.nil? || fail_results.length == 0)
28
+ f.send!([:pass_results, "."])
29
+ else
30
+ f.send!([:pass_results, pass_results]) unless pass_results.nil? or pass_results.length == 0
31
+ f.send!([:fail_results, fail_results]) unless fail_results.nil? or fail_results.length == 0
32
+ f.send!([:total_time_for_file, text, total_time_for_file])
33
+ f.send!([:profile, text, profile])
34
+ f.send!([:captured_std_err_out, captured_std_err_out]) unless captured_std_err_out == ""
35
+ end
36
+ f.send!(:ready_for_file)
37
+ f.receive_loop
38
+ end
39
+ #stops the loop causing it to stop
40
+ f.when(:stop) { f.send!([:port_shutdown, "normal"]) }
41
+
42
+ f.when([:object, Any]) do |obj|
43
+ puts "in ruby in Any with obj #{obj.inspect}"
44
+ f.send!([:barf, "Barf in ruby with obj #{obj.inspect}"])
45
+ f.receive_loop
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec/runner/formatter/base_formatter'
2
+ module Distributest
3
+ module Formatter
4
+ class BasicFormat < Spec::Runner::Formatter::BaseFormatter
5
+ attr_accessor :output, :errors
6
+
7
+ def initialize(output, errors, profile)
8
+ @output = output
9
+ @errors = errors
10
+ @profile = profile
11
+ end
12
+
13
+ def dump_summary(duration, example, failure, pending)
14
+ #hiding summary atm
15
+ end
16
+
17
+ def example_started(example)
18
+ @time = Time.now
19
+ end
20
+
21
+ def example_passed(example)
22
+ @profile << [example.description, Time.now - @time]
23
+ output << '.'
24
+ end
25
+
26
+ def example_failed(example_proxy, counter, failure)
27
+ errors << [failure.header.to_s, failure.exception.to_s, failure.exception.backtrace.join("\n")]
28
+ end
29
+
30
+ def example_pending(example_proxy, message, deprecated_pending_location = nil)
31
+ output << '*'
32
+ end
33
+
34
+ def dump_failure(counter, failure)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ require 'distributest/formatter'
2
+ module Distributest
3
+ class TestRunner
4
+
5
+ def capture_output
6
+ @stdout = StringIO.new
7
+ @stderr = StringIO.new
8
+ $stderr = @stderr
9
+ $stdout = @stdout
10
+ end
11
+
12
+ def captured_output
13
+ [@stdout.string, @stderr.string]
14
+ end
15
+
16
+ def run_rspec_file(file)
17
+ capture_output
18
+
19
+ start_time = Time.now
20
+ begin
21
+ require 'spec'
22
+
23
+ rescue LoadError => ex
24
+ return ex.to_s
25
+ end
26
+
27
+ output = []
28
+ errors = []
29
+ profile = []
30
+
31
+ Spec::Runner.options.instance_variable_set(:@formatters,
32
+ [Distributest::Formatter::BasicFormat.new(output, errors, profile)])
33
+ Spec::Runner.options.instance_variable_set(:@example_groups, [])
34
+ Spec::Runner.options.instance_variable_set(:@files, [file])
35
+ Spec::Runner.options.instance_variable_set(:@files_loaded, false)
36
+
37
+ if file == ""
38
+ return nil
39
+ else
40
+ Spec::Runner.options.run_examples
41
+ end
42
+ end_time = Time.now
43
+ total_time_for_file = end_time - start_time
44
+
45
+ out, err = captured_output
46
+
47
+ return output, errors, profile, total_time_for_file, out + err
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module Distributest
2
+ VERSION = '0.0.6'
3
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: distributest
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 6
10
+ version: 0.0.6
11
+ platform: ruby
12
+ authors:
13
+ - Curtis Carter
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-20 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: erlectricity
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 17
30
+ segments:
31
+ - 1
32
+ - 1
33
+ - 1
34
+ version: 1.1.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Uses erlectricity to communicate with the distributest Erlang application
38
+ email:
39
+ - curtis@rubyhq.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - lib/distributest/formatter.rb
48
+ - lib/distributest/test_runner.rb
49
+ - lib/distributest/version.rb
50
+ - lib/distributest.rb
51
+ has_rdoc: true
52
+ homepage: http://github.com/ccarter/distributest
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 23
75
+ segments:
76
+ - 1
77
+ - 3
78
+ - 6
79
+ version: 1.3.6
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.6.2
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Ruby component of the Erlang based distributed test runner
87
+ test_files: []
88
+