deep_test 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/CHANGELOG +6 -0
  2. data/README +39 -2
  3. data/Rakefile +17 -12
  4. data/lib/deep_test.rb +27 -18
  5. data/lib/deep_test/deadlock_detector.rb +7 -0
  6. data/lib/deep_test/logger.rb +9 -0
  7. data/lib/deep_test/null_worker_listener.rb +12 -0
  8. data/lib/deep_test/options.rb +72 -0
  9. data/lib/deep_test/process_orchestrator.rb +85 -0
  10. data/lib/deep_test/rake_tasks.rb +7 -0
  11. data/lib/deep_test/rinda_blackboard.rb +8 -7
  12. data/lib/deep_test/rspec_detector.rb +17 -0
  13. data/lib/deep_test/server.rb +3 -9
  14. data/lib/deep_test/spec.rb +9 -0
  15. data/lib/deep_test/spec/extensions/options.rb +11 -0
  16. data/lib/deep_test/spec/extensions/reporter.rb +17 -0
  17. data/lib/deep_test/spec/extensions/spec_task.rb +13 -0
  18. data/lib/deep_test/spec/runner.rb +48 -0
  19. data/lib/deep_test/spec/work_result.rb +26 -0
  20. data/lib/deep_test/spec/work_unit.rb +53 -0
  21. data/lib/deep_test/test.rb +9 -0
  22. data/lib/deep_test/{extensions → test/extensions}/error.rb +0 -0
  23. data/lib/deep_test/{extensions/testresult.rb → test/extensions/test_result.rb} +1 -1
  24. data/lib/deep_test/test/runner.rb +29 -0
  25. data/lib/deep_test/test/supervised_test_suite.rb +46 -0
  26. data/lib/deep_test/test/work_unit.rb +36 -0
  27. data/lib/deep_test/test_task.rb +36 -9
  28. data/lib/deep_test/tuple_space_factory.rb +3 -2
  29. data/lib/deep_test/warlock.rb +2 -2
  30. data/lib/deep_test/worker.rb +10 -20
  31. data/script/run_test_suite.rb +5 -34
  32. data/test/deep_test/rinda_blackboard_test.rb +5 -5
  33. data/test/{testresult_test.rb → deep_test/test/extensions/test_result_test.rb} +2 -2
  34. data/test/deep_test/test/runner_test.rb +7 -0
  35. data/test/deep_test/test/supervised_test_suite_test.rb +89 -0
  36. data/test/deep_test/test/work_unit_test.rb +50 -0
  37. data/test/deep_test/test_task_test.rb +23 -0
  38. data/test/deep_test/worker_test.rb +62 -0
  39. data/test/failing.rake +11 -0
  40. data/test/fake_deadlock_error.rb +12 -0
  41. data/test/logger_test.rb +11 -0
  42. data/test/simple_test_blackboard.rb +44 -0
  43. data/test/simple_test_blackboard_test.rb +5 -5
  44. data/test/test_factory.rb +74 -0
  45. data/test/test_helper.rb +5 -71
  46. metadata +32 -13
  47. data/lib/deep_test/loader.rb +0 -18
  48. data/lib/deep_test/simple_test_blackboard.rb +0 -24
  49. data/lib/deep_test/supervised_test_suite.rb +0 -19
  50. data/lib/deep_test/supervisor.rb +0 -27
  51. data/test/deep_test/loader_test.rb +0 -8
  52. data/test/supervised_test_suite_test.rb +0 -63
  53. data/test/supervisor_test.rb +0 -80
  54. data/test/worker_test.rb +0 -64
@@ -2,79 +2,13 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'dust'
4
4
  require 'mocha'
5
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/lib")
5
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
6
6
  require "deep_test"
7
7
 
8
- module TestFactory
9
- def self.failing_test
10
- test_class = Class.new(Test::Unit::TestCase) do
11
- def test_failing
12
- assert_equal 1, 0
13
- end
14
- end
15
- test_class.new(:test_failing)
16
- end
17
-
18
- def self.passed_result
19
- result = Test::Unit::TestResult.new
20
- result.add_run
21
- result.add_assertion
22
- result
23
- end
24
-
25
- def self.passing_test
26
- test_class = Class.new(Test::Unit::TestCase) do
27
- def test_passing
28
- assert_equal 0, 0
29
- end
30
- end
31
- test_class.new(:test_passing)
32
- end
33
-
34
- def self.passing_test_with_stdout
35
- test_class = Class.new(Test::Unit::TestCase) do
36
- def test_passing_with_stdout
37
- print "message printed to stdout"
38
- assert true
39
- end
40
- end
41
- test_class.new :test_passing_with_stdout
42
- end
43
-
44
- def self.deadlock_once_test
45
- test_class = Class.new(Test::Unit::TestCase) do
46
- def test_deadlock_once
47
- if @deadlocked
48
- assert true
49
- else
50
- @deadlocked = true
51
- raise ActiveRecord::StatementInvalid.new("Deadlock found when trying to get lock")
52
- end
53
- end
54
- end
55
- test_class.new :test_deadlock_once
56
- end
57
-
58
- def self.deadlock_always_test
59
- test_class = Class.new(Test::Unit::TestCase) do
60
- def test_deadlock_always
61
- raise ActiveRecord::StatementInvalid.new("Deadlock found when trying to get lock")
62
- end
63
- end
64
- test_class.new :test_deadlock_always
65
- end
66
-
67
- def self.suite
68
- Test::Unit::TestSuite.new
69
- end
70
- end
8
+ require File.dirname(__FILE__) + "/fake_deadlock_error"
9
+ require File.dirname(__FILE__) + "/simple_test_blackboard"
10
+ require File.dirname(__FILE__) + "/test_factory"
11
+ require File.dirname(__FILE__) + "/../spec/thread_worker"
71
12
 
72
13
  class SomeCustomException < RuntimeError
73
14
  end
74
-
75
- unless defined?(ActiveRecord::StatementInvalid)
76
- module ActiveRecord
77
- class StatementInvalid < StandardError
78
- end
79
- end
80
- end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: deep_test
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.2
7
- date: 2008-02-09 00:00:00 -05:00
6
+ version: 1.1.3
7
+ date: 2008-03-10 00:00:00 -04:00
8
8
  summary: DeepTest runs tests in multiple processes.
9
9
  require_paths:
10
10
  - lib
@@ -30,33 +30,52 @@ authors:
30
30
  - anonymous z, Dan Manges, David Vollbracht
31
31
  files:
32
32
  - lib/deep_test.rb
33
- - lib/deep_test/loader.rb
33
+ - lib/deep_test/deadlock_detector.rb
34
+ - lib/deep_test/logger.rb
35
+ - lib/deep_test/null_worker_listener.rb
36
+ - lib/deep_test/options.rb
37
+ - lib/deep_test/process_orchestrator.rb
34
38
  - lib/deep_test/rake_tasks.rb
35
39
  - lib/deep_test/rinda_blackboard.rb
40
+ - lib/deep_test/rspec_detector.rb
36
41
  - lib/deep_test/server.rb
37
- - lib/deep_test/simple_test_blackboard.rb
38
- - lib/deep_test/supervised_test_suite.rb
39
- - lib/deep_test/supervisor.rb
42
+ - lib/deep_test/spec.rb
43
+ - lib/deep_test/test.rb
40
44
  - lib/deep_test/test_task.rb
41
45
  - lib/deep_test/tuple_space_factory.rb
42
46
  - lib/deep_test/warlock.rb
43
47
  - lib/deep_test/worker.rb
44
- - lib/deep_test/extensions/error.rb
45
48
  - lib/deep_test/extensions/object_extension.rb
46
- - lib/deep_test/extensions/testresult.rb
49
+ - lib/deep_test/spec/runner.rb
50
+ - lib/deep_test/spec/work_result.rb
51
+ - lib/deep_test/spec/work_unit.rb
52
+ - lib/deep_test/spec/extensions/options.rb
53
+ - lib/deep_test/spec/extensions/reporter.rb
54
+ - lib/deep_test/spec/extensions/spec_task.rb
55
+ - lib/deep_test/test/runner.rb
56
+ - lib/deep_test/test/supervised_test_suite.rb
57
+ - lib/deep_test/test/work_unit.rb
58
+ - lib/deep_test/test/extensions/error.rb
59
+ - lib/deep_test/test/extensions/test_result.rb
47
60
  - script/run_test_suite.rb
48
61
  - test/failing.rb
62
+ - test/fake_deadlock_error.rb
63
+ - test/logger_test.rb
64
+ - test/simple_test_blackboard.rb
49
65
  - test/simple_test_blackboard_test.rb
50
- - test/supervised_test_suite_test.rb
51
- - test/supervisor_test.rb
66
+ - test/test_factory.rb
52
67
  - test/test_helper.rb
53
68
  - test/test_task_test.rb
54
- - test/testresult_test.rb
55
- - test/worker_test.rb
56
- - test/deep_test/loader_test.rb
57
69
  - test/deep_test/rinda_blackboard_test.rb
70
+ - test/deep_test/test_task_test.rb
58
71
  - test/deep_test/warlock_test.rb
72
+ - test/deep_test/worker_test.rb
59
73
  - test/deep_test/extensions/object_extension_test.rb
74
+ - test/deep_test/test/runner_test.rb
75
+ - test/deep_test/test/supervised_test_suite_test.rb
76
+ - test/deep_test/test/work_unit_test.rb
77
+ - test/deep_test/test/extensions/test_result_test.rb
78
+ - test/failing.rake
60
79
  - README
61
80
  - CHANGELOG
62
81
  - Rakefile
@@ -1,18 +0,0 @@
1
- module DeepTest
2
- class Loader
3
- NO_FILTERS = Object.new.instance_eval do
4
- def filters; []; end;
5
- self
6
- end
7
-
8
- def self.run
9
- require "deep_test"
10
- suite = Test::Unit::AutoRunner::COLLECTORS[:objectspace].call NO_FILTERS
11
- supervised_suite = DeepTest::SupervisedTestSuite.new(suite)
12
- require 'test/unit/ui/console/testrunner'
13
- result = Test::Unit::UI::Console::TestRunner.run(supervised_suite, Test::Unit::UI::NORMAL)
14
- Test::Unit.run = true
15
- return result.passed?
16
- end
17
- end
18
- end
@@ -1,24 +0,0 @@
1
- module DeepTest
2
- class SimpleTestBlackboard
3
- def initialize
4
- @test_cases = []
5
- @test_results = []
6
- end
7
-
8
- def take_result
9
- @test_results.shift
10
- end
11
-
12
- def take_test
13
- @test_cases.shift
14
- end
15
-
16
- def write_result(result)
17
- @test_results.push result
18
- end
19
-
20
- def write_test(test_case)
21
- @test_cases.push test_case
22
- end
23
- end
24
- end
@@ -1,19 +0,0 @@
1
- module DeepTest
2
- class SupervisedTestSuite
3
- def initialize(suite, supervisor = DeepTest::Supervisor.new)
4
- @suite = suite
5
- @supervisor = supervisor
6
- end
7
-
8
- def run(result, &progress_block)
9
- yield Test::Unit::TestSuite::STARTED, @suite.name
10
- @supervisor.add_tests @suite
11
- @supervisor.read_results result, &progress_block
12
- yield Test::Unit::TestSuite::FINISHED, @suite.name
13
- end
14
-
15
- def size
16
- @suite.size
17
- end
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- module DeepTest
2
- class Supervisor
3
- def initialize(blackboard = DeepTest::RindaBlackboard.new)
4
- @blackboard = blackboard
5
- @count = 0
6
- end
7
-
8
- def add_tests(test_suite)
9
- if test_suite.respond_to? :tests
10
- test_suite.tests.each {|test| add_tests(test)}
11
- else
12
- @count += 1
13
- @blackboard.write_test test_suite
14
- end
15
- end
16
-
17
- def read_results(result)
18
- while (@count > 0 && remote_result = @blackboard.take_result)
19
- @count -= 1
20
- remote_result.add_to result
21
- # TODO: is this the right place for this next line? -Dan
22
- print remote_result.output if remote_result.output
23
- yield Test::Unit::TestCase::FINISHED, nil if block_given?
24
- end
25
- end
26
- end
27
- end
@@ -1,8 +0,0 @@
1
- require File.dirname(__FILE__) + "/../test_helper"
2
- require "deep_test/loader" unless defined?(DeepTest::Loader)
3
-
4
- unit_tests do
5
- test "no filters constant has empty filters" do
6
- assert_equal [], DeepTest::Loader::NO_FILTERS.filters
7
- end
8
- end
@@ -1,63 +0,0 @@
1
- require File.dirname(__FILE__) + "/test_helper"
2
-
3
- unit_tests do
4
- test "run yields name for start and finished of underlying suite" do
5
- suite = Test::Unit::TestSuite.new("name")
6
- supervised_suite = DeepTest::SupervisedTestSuite.new(suite, stub_everything)
7
-
8
- yielded = []
9
- supervised_suite.run(stub_everything) do |channel,name|
10
- yielded << [channel,name]
11
- end
12
-
13
- assert_equal [[Test::Unit::TestSuite::STARTED, "name"],
14
- [Test::Unit::TestSuite::FINISHED, "name"]], yielded
15
- end
16
-
17
- test "run adds test suite to supervisor" do
18
- suite = Test::Unit::TestSuite.new("name")
19
- supervisor = stub_everything
20
- supervised_suite = DeepTest::SupervisedTestSuite.new(suite, supervisor)
21
- supervisor.expects(:add_tests).with(suite)
22
- supervised_suite.run(stub_everything) {|channel,name|}
23
- end
24
-
25
-
26
- test "run tells supervisor to read resuts with passed in results" do
27
- suite = Test::Unit::TestSuite.new("name")
28
- results = stub_everything
29
- supervisor = stub_everything
30
- supervised_suite = DeepTest::SupervisedTestSuite.new(suite, supervisor)
31
- supervisor.expects(:read_results).with(results)
32
- supervised_suite.run(results) {|channel,name|}
33
- end
34
-
35
-
36
- test "run passes progress block on to supervisor" do
37
- suite = Test::Unit::TestSuite.new("name")
38
- supervisor = stub_everything
39
- supervised_suite = DeepTest::SupervisedTestSuite.new(suite, supervisor)
40
- supervisor.stubs(:read_results).yields("from_supervisor", "event")
41
- yielded = []
42
- supervised_suite.run(stub_everything) do |channel,name|
43
- yielded << [channel, name]
44
- end
45
-
46
- assert_equal true, yielded.include?(["from_supervisor", "event"])
47
- end
48
-
49
- test "has same size as underlyng suite" do
50
- suite = Test::Unit::TestSuite.new("name")
51
- suite << "test"
52
- supervisor = stub_everything
53
- supervised_suite = DeepTest::SupervisedTestSuite.new(suite, supervisor)
54
-
55
- assert_equal suite.size, supervised_suite.size
56
- end
57
-
58
- test "defaults to using DeepTest::Supervisor" do
59
- DeepTest::Supervisor.stubs(:new).returns(:supervisor)
60
- supervised_suite = DeepTest::SupervisedTestSuite.new(stub)
61
- assert_equal :supervisor, supervised_suite.instance_variable_get("@supervisor")
62
- end
63
- end
@@ -1,80 +0,0 @@
1
- require File.dirname(__FILE__) + "/test_helper"
2
-
3
- unit_tests do
4
- test "add_tests adds single test to blackboard" do
5
- blackboard = DeepTest::SimpleTestBlackboard.new
6
- supervisor = DeepTest::Supervisor.new(blackboard)
7
- test_case = TestFactory.passing_test
8
- supervisor.add_tests test_case
9
- assert_equal test_case, blackboard.take_test
10
- end
11
-
12
- test "add_tests adds entire suite to blackboard" do
13
- blackboard = DeepTest::SimpleTestBlackboard.new
14
- supervisor = DeepTest::Supervisor.new(blackboard)
15
- test_suite = TestFactory.suite
16
- test_suite << (test_case_1 = TestFactory.passing_test)
17
- test_suite << (test_case_2 = TestFactory.passing_test)
18
-
19
- supervisor.add_tests test_suite
20
-
21
- actual_tests = [blackboard.take_test, blackboard.take_test]
22
-
23
- assert_equal true, actual_tests.member?(test_case_1),
24
- "First test case is not on blackboard"
25
-
26
- assert_equal true, actual_tests.member?(test_case_2),
27
- "Second test case is not on blackboard"
28
- end
29
-
30
- test "read_results adds blackboard result to local result" do
31
- blackboard = DeepTest::SimpleTestBlackboard.new
32
- supervisor = DeepTest::Supervisor.new(blackboard)
33
-
34
- supervisor.add_tests TestFactory.passing_test
35
-
36
- blackboard_result = Test::Unit::TestResult.new
37
- blackboard_result.add_run
38
-
39
- blackboard.write_result blackboard_result
40
-
41
- local_result = Test::Unit::TestResult.new
42
- supervisor.read_results local_result
43
-
44
- assert_equal 1, local_result.run_count
45
- end
46
-
47
- test "read_results yields TestCase::Finished event when reading a result" do
48
- blackboard = DeepTest::SimpleTestBlackboard.new
49
- supervisor = DeepTest::Supervisor.new(blackboard)
50
-
51
- supervisor.add_tests TestFactory.passing_test
52
-
53
- blackboard.write_result Test::Unit::TestResult.new
54
- yielded = nil
55
-
56
- supervisor.read_results Test::Unit::TestResult.new do |channel,name|
57
- yielded = [channel,name]
58
- end
59
-
60
- assert_equal [Test::Unit::TestCase::FINISHED, nil], yielded
61
- end
62
-
63
- test "read_results prints output if any" do
64
- blackboard = DeepTest::SimpleTestBlackboard.new
65
- supervisor = DeepTest::Supervisor.new(blackboard)
66
- supervisor.add_tests stub
67
- result = Test::Unit::TestResult.new
68
- result.output = "output"
69
- blackboard.write_result result
70
- supervisor.expects(:print).with("output")
71
- supervisor.read_results Test::Unit::TestResult.new do |channel,name|
72
- end
73
- end
74
-
75
- test "defaults to using a rinda blackboard" do
76
- DeepTest::RindaBlackboard.stubs(:new).returns(:rinda_blackboard)
77
- supervisor = DeepTest::Supervisor.new
78
- assert_equal :rinda_blackboard, supervisor.instance_variable_get("@blackboard")
79
- end
80
- end
@@ -1,64 +0,0 @@
1
- require File.dirname(__FILE__) + "/test_helper"
2
-
3
- unit_tests do
4
- test "puts result on blackboard" do
5
- blackboard = DeepTest::SimpleTestBlackboard.new
6
- blackboard.write_test TestFactory.passing_test
7
-
8
- DeepTest::Worker.new(blackboard).run
9
-
10
- assert_kind_of Test::Unit::TestResult, blackboard.take_result
11
- end
12
-
13
- test "puts passing and failing tests on blackboard for each test" do
14
- blackboard = DeepTest::SimpleTestBlackboard.new
15
- blackboard.write_test TestFactory.passing_test
16
- blackboard.write_test TestFactory.failing_test
17
-
18
- DeepTest::Worker.new(blackboard).run
19
-
20
- result_1 = blackboard.take_result
21
- result_2 = blackboard.take_result
22
-
23
- assert_equal true, (result_1.passed? || result_2.passed?)
24
- assert_equal false, (result_1.passed? && result_2.passed?)
25
- end
26
-
27
- test "capturing stdout" do
28
- blackboard = DeepTest::SimpleTestBlackboard.new
29
- blackboard.write_test TestFactory.passing_test_with_stdout
30
- DeepTest::Worker.new(blackboard).run
31
- result = blackboard.take_result
32
- assert_equal "message printed to stdout", result.output
33
- end
34
-
35
- test "retry on deadlock" do
36
- blackboard = DeepTest::SimpleTestBlackboard.new
37
- blackboard.write_test TestFactory.deadlock_once_test
38
- DeepTest::Worker.new(blackboard).run
39
- result = blackboard.take_result
40
- assert_equal 0, result.error_count
41
- assert_equal 0, result.failure_count
42
- assert_equal 1, result.assertion_count
43
- end
44
-
45
- test "skip on deadlock twice" do
46
- blackboard = DeepTest::SimpleTestBlackboard.new
47
- blackboard.write_test TestFactory.deadlock_always_test
48
- DeepTest::Worker.new(blackboard).run
49
- result = blackboard.take_result
50
- assert_equal 0, result.error_count
51
- assert_equal 0, result.failure_count
52
- assert_equal 0, result.assertion_count
53
- end
54
-
55
- test "does not fork from rake" do
56
- assert !defined?(Rake)
57
- end
58
-
59
- test "defaults to using a rinda blackboard" do
60
- DeepTest::RindaBlackboard.stubs(:new).returns(:rinda_blackboard)
61
- worker = DeepTest::Worker.new
62
- assert_equal :rinda_blackboard, worker.instance_variable_get("@blackboard")
63
- end
64
- end