jason-o-matic-deep_test 1.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +47 -0
- data/README.rdoc +228 -0
- data/Rakefile +211 -0
- data/bin/deep_test +15 -0
- data/lib/deep_test.rb +90 -0
- data/lib/deep_test/database/mysql_setup_listener.rb +113 -0
- data/lib/deep_test/database/setup_listener.rb +116 -0
- data/lib/deep_test/deadlock_detector.rb +7 -0
- data/lib/deep_test/distributed/dispatch_controller.rb +53 -0
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
- data/lib/deep_test/distributed/filename_resolver.rb +40 -0
- data/lib/deep_test/distributed/master_test_server.rb +52 -0
- data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
- data/lib/deep_test/distributed/null_work_unit.rb +12 -0
- data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
- data/lib/deep_test/distributed/remote_worker_server.rb +111 -0
- data/lib/deep_test/distributed/rsync.rb +37 -0
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +79 -0
- data/lib/deep_test/distributed/test_server_status.rb +9 -0
- data/lib/deep_test/distributed/test_server_workers.rb +24 -0
- data/lib/deep_test/distributed/throughput_runner.rb +42 -0
- data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
- data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
- data/lib/deep_test/extensions/drb_extension.rb +34 -0
- data/lib/deep_test/extensions/object_extension.rb +40 -0
- data/lib/deep_test/listener_list.rb +17 -0
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +17 -0
- data/lib/deep_test/marshallable_exception_wrapper.rb +44 -0
- data/lib/deep_test/metrics/gatherer.rb +67 -0
- data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
- data/lib/deep_test/null_worker_listener.rb +65 -0
- data/lib/deep_test/option.rb +70 -0
- data/lib/deep_test/options.rb +112 -0
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +11 -0
- data/lib/deep_test/result_reader.rb +36 -0
- data/lib/deep_test/rspec_detector.rb +24 -0
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +12 -0
- data/lib/deep_test/spec/extensions/example_group_methods.rb +64 -0
- data/lib/deep_test/spec/extensions/example_methods.rb +46 -0
- data/lib/deep_test/spec/extensions/options.rb +43 -0
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +20 -0
- data/lib/deep_test/spec/runner.rb +57 -0
- data/lib/deep_test/spec/work_result.rb +33 -0
- data/lib/deep_test/spec/work_unit.rb +59 -0
- data/lib/deep_test/test.rb +10 -0
- data/lib/deep_test/test/extensions/error.rb +14 -0
- data/lib/deep_test/test/runner.rb +24 -0
- data/lib/deep_test/test/supervised_test_suite.rb +49 -0
- data/lib/deep_test/test/work_result.rb +34 -0
- data/lib/deep_test/test/work_unit.rb +40 -0
- data/lib/deep_test/test_task.rb +51 -0
- data/lib/deep_test/ui/console.rb +76 -0
- data/lib/deep_test/ui/null.rb +17 -0
- data/lib/deep_test/warlock.rb +134 -0
- data/lib/deep_test/worker.rb +57 -0
- data/script/internal/run_test_suite.rb +7 -0
- data/script/public/master_test_server.rb +24 -0
- data/script/public/test_server.rb +18 -0
- data/script/public/test_throughput.rb +29 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +14 -0
- data/test/deep_test/distributed/dispatch_controller_test.rb +209 -0
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +52 -0
- data/test/deep_test/distributed/master_test_server_test.rb +32 -0
- data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
- data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
- data/test/deep_test/distributed/remote_worker_server_test.rb +107 -0
- data/test/deep_test/distributed/rsync_test.rb +67 -0
- data/test/deep_test/distributed/test_server_test.rb +94 -0
- data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
- data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
- data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
- data/test/deep_test/extensions/object_extension_test.rb +37 -0
- data/test/deep_test/listener_list_test.rb +20 -0
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +11 -0
- data/test/deep_test/marshallable_exception_wrapper_test.rb +44 -0
- data/test/deep_test/metrics/gatherer_test.rb +66 -0
- data/test/deep_test/process_orchestrator_test.rb +11 -0
- data/test/deep_test/result_reader_test.rb +128 -0
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +40 -0
- data/test/deep_test/test/runner_test.rb +7 -0
- data/test/deep_test/test/supervised_test_suite_test.rb +79 -0
- data/test/deep_test/test/work_result_test.rb +81 -0
- data/test/deep_test/test/work_unit_test.rb +61 -0
- data/test/deep_test/test_task_test.rb +43 -0
- data/test/deep_test/ui/console_test.rb +9 -0
- data/test/deep_test/warlock_test.rb +38 -0
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/test/failing.rb +7 -0
- data/test/fake_deadlock_error.rb +12 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/test/test_factory.rb +74 -0
- data/test/test_helper.rb +15 -0
- data/test/test_task_test.rb +72 -0
- metadata +160 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "take_work returns result of push_work when it is available" do
|
5
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
6
|
+
server.write_work :work
|
7
|
+
assert_equal :work, server.take_work
|
8
|
+
end
|
9
|
+
|
10
|
+
test "take_work raises error when no work is currently available" do
|
11
|
+
assert_raises(DeepTest::Server::NoWorkUnitsAvailableError) do
|
12
|
+
DeepTest::Server.new(DeepTest::Options.new({})).take_work
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
test "take_work raises error when there is no work left to" do
|
17
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
18
|
+
server.done_with_work
|
19
|
+
|
20
|
+
assert_raises(DeepTest::Server::NoWorkUnitsRemainingError) do
|
21
|
+
server.take_work
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
test "take_result returns result of push_result when it is available" do
|
26
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
27
|
+
t = Thread.new {server.take_result}
|
28
|
+
server.write_result :result
|
29
|
+
assert_equal :result, t.value
|
30
|
+
end
|
31
|
+
|
32
|
+
test "take_result timeouts out after configurable number of seconds" do
|
33
|
+
server = DeepTest::Server.new(
|
34
|
+
DeepTest::Options.new(:timeout_in_seconds => 0.01)
|
35
|
+
)
|
36
|
+
Thread.new {sleep 0.1; server.write_result :too_late}
|
37
|
+
assert_raises(DeepTest::Server::ResultOverdueError) {server.take_result}
|
38
|
+
end
|
39
|
+
|
40
|
+
test "write_work returns nil" do
|
41
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
42
|
+
assert_equal nil, server.write_work(:a)
|
43
|
+
end
|
44
|
+
|
45
|
+
test "write_result returns nil" do
|
46
|
+
server = DeepTest::Server.new(DeepTest::Options.new({}))
|
47
|
+
assert_equal nil, server.write_result(:a)
|
48
|
+
end
|
49
|
+
|
50
|
+
test "start returns instance of server" do
|
51
|
+
DRb.expects(:start_service)
|
52
|
+
DRb.expects(:uri)
|
53
|
+
DeepTest.logger.expects(:info)
|
54
|
+
|
55
|
+
server = DeepTest::Server.start(DeepTest::Options.new({}))
|
56
|
+
assert_kind_of DeepTest::Server, server
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "make_exception_marshallable wraps exception in a mashallable exception" do
|
5
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
6
|
+
error.make_exception_marshallable
|
7
|
+
|
8
|
+
assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
|
9
|
+
end
|
10
|
+
|
11
|
+
test "calling make_exception_marshallable twice only wraps exception once" do
|
12
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
13
|
+
error.make_exception_marshallable
|
14
|
+
error.make_exception_marshallable
|
15
|
+
|
16
|
+
assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
|
17
|
+
end
|
18
|
+
|
19
|
+
test "error is accessible as normal when it has not been made marshallable" do
|
20
|
+
error = Test::Unit::Error.new "test_name", e = Exception.new("message")
|
21
|
+
assert_equal e, error.exception
|
22
|
+
end
|
23
|
+
|
24
|
+
test "resolve_marshallable_exception restores the original exception" do
|
25
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
26
|
+
error.make_exception_marshallable
|
27
|
+
error.resolve_marshallable_exception
|
28
|
+
|
29
|
+
assert_kind_of Exception, error.exception
|
30
|
+
assert_equal 'message', error.exception.message
|
31
|
+
end
|
32
|
+
|
33
|
+
test "resolve_marshallable_exception does not fail when exception has not been made marshallable" do
|
34
|
+
error = Test::Unit::Error.new "test_name", Exception.new("message")
|
35
|
+
error.resolve_marshallable_exception
|
36
|
+
|
37
|
+
assert_kind_of Exception, error.exception
|
38
|
+
assert_equal 'message', error.exception.message
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,79 @@
|
|
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::Test::SupervisedTestSuite.new(suite, DeepTest::SimpleTestBlackboard.new)
|
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 tests to blackboard and reads results" do
|
18
|
+
test_case_class = Class.new(Test::Unit::TestCase) do
|
19
|
+
test("1") {}
|
20
|
+
test("2") {assert_equal true, false}
|
21
|
+
end
|
22
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
23
|
+
supervised_suite = DeepTest::Test::SupervisedTestSuite.new(test_case_class.suite, blackboard)
|
24
|
+
result = Test::Unit::TestResult.new
|
25
|
+
|
26
|
+
worker = ThreadWorker.new(blackboard, 2)
|
27
|
+
Timeout.timeout(5) do
|
28
|
+
supervised_suite.run(result) {}
|
29
|
+
end
|
30
|
+
worker.wait_until_done
|
31
|
+
|
32
|
+
assert_equal 2, result.run_count
|
33
|
+
assert_equal 1, result.failure_count
|
34
|
+
end
|
35
|
+
|
36
|
+
test "worker errors are counted as errors" do
|
37
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
38
|
+
test("1") {}
|
39
|
+
end.new("test_1")
|
40
|
+
|
41
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
42
|
+
supervised_suite = DeepTest::Test::SupervisedTestSuite.new(test_case, blackboard)
|
43
|
+
result = Test::Unit::TestResult.new
|
44
|
+
|
45
|
+
blackboard.write_result DeepTest::Worker::Error.new(test_case, RuntimeError.new)
|
46
|
+
capture_stdout {supervised_suite.run(result) {}}
|
47
|
+
|
48
|
+
assert_equal 1, result.error_count
|
49
|
+
end
|
50
|
+
|
51
|
+
test "run yields test case finished events" do
|
52
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
53
|
+
test("1") {}
|
54
|
+
end.new("test_1")
|
55
|
+
|
56
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
57
|
+
supervised_suite = DeepTest::Test::SupervisedTestSuite.new(test_case, blackboard)
|
58
|
+
|
59
|
+
yielded = []
|
60
|
+
|
61
|
+
worker = ThreadWorker.new(blackboard, 1)
|
62
|
+
Timeout.timeout(5) do
|
63
|
+
supervised_suite.run(stub_everything) do |channel,name|
|
64
|
+
yielded << [channel, name]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
worker.wait_until_done
|
68
|
+
|
69
|
+
assert_equal true, yielded.include?([::Test::Unit::TestCase::FINISHED, test_case.name])
|
70
|
+
end
|
71
|
+
|
72
|
+
test "has same size as underlying suite" do
|
73
|
+
suite = Test::Unit::TestSuite.new("name")
|
74
|
+
suite << "test"
|
75
|
+
supervised_suite = DeepTest::Test::SupervisedTestSuite.new(suite, DeepTest::SimpleTestBlackboard.new)
|
76
|
+
|
77
|
+
assert_equal suite.size, supervised_suite.size
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "add_to adds correct run_count" do
|
5
|
+
result_1 = DeepTest::Test::WorkResult.new "test_name"
|
6
|
+
result_1.add_run
|
7
|
+
result_1.add_run
|
8
|
+
|
9
|
+
result_2 = Test::Unit::TestResult.new
|
10
|
+
result_1.add_to result_2
|
11
|
+
|
12
|
+
assert_equal 2, result_2.run_count
|
13
|
+
end
|
14
|
+
|
15
|
+
test "add_to adds correct assertion_count" do
|
16
|
+
result_1 = DeepTest::Test::WorkResult.new "test_name"
|
17
|
+
result_1.add_assertion
|
18
|
+
result_1.add_assertion
|
19
|
+
|
20
|
+
result_2 = Test::Unit::TestResult.new
|
21
|
+
result_1.add_to result_2
|
22
|
+
|
23
|
+
assert_equal 2, result_2.assertion_count
|
24
|
+
end
|
25
|
+
|
26
|
+
test "add_to adds correct errors" do
|
27
|
+
result_1 = DeepTest::Test::WorkResult.new "test_name"
|
28
|
+
result_1.add_error(e = Test::Unit::Error.new("test_name", Exception.new))
|
29
|
+
|
30
|
+
result_2 = Test::Unit::TestResult.new
|
31
|
+
result_1.add_to result_2
|
32
|
+
|
33
|
+
assert_equal [e], result_2.instance_variable_get(:@errors)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
test "add_to adds correct failures" do
|
38
|
+
result_1 = DeepTest::Test::WorkResult.new "test_name"
|
39
|
+
result_1.add_failure(:failure)
|
40
|
+
|
41
|
+
result_2 = Test::Unit::TestResult.new
|
42
|
+
result_1.add_to result_2
|
43
|
+
|
44
|
+
assert_equal [:failure], result_2.instance_variable_get(:@failures)
|
45
|
+
end
|
46
|
+
|
47
|
+
test "add_error wraps exceptions" do
|
48
|
+
result = DeepTest::Test::WorkResult.new "test_name"
|
49
|
+
result.add_error Test::Unit::Error.new(
|
50
|
+
"test_wraps_exceptions",
|
51
|
+
SomeCustomException.new("the exception message")
|
52
|
+
)
|
53
|
+
|
54
|
+
error = result.instance_variable_get("@errors").last
|
55
|
+
assert_kind_of DeepTest::MarshallableExceptionWrapper, error.exception
|
56
|
+
end
|
57
|
+
|
58
|
+
test "add_to unwraps exception" do
|
59
|
+
work_result = DeepTest::Test::WorkResult.new "test_name"
|
60
|
+
work_result.add_error Test::Unit::Error.new(
|
61
|
+
"test_wraps_exceptions",
|
62
|
+
SomeCustomException.new("the exception message")
|
63
|
+
)
|
64
|
+
|
65
|
+
test_result = ::Test::Unit::TestResult.new
|
66
|
+
work_result.add_to(test_result)
|
67
|
+
|
68
|
+
error = test_result.instance_variable_get("@errors").last
|
69
|
+
assert_kind_of SomeCustomException, error.exception
|
70
|
+
end
|
71
|
+
|
72
|
+
test "failed due to deadlock" do
|
73
|
+
result = DeepTest::Test::WorkResult.new "test_name"
|
74
|
+
begin
|
75
|
+
raise FakeDeadlockError.new
|
76
|
+
rescue => ex
|
77
|
+
result.add_error Test::Unit::Error.new("test_", ex)
|
78
|
+
end
|
79
|
+
assert_equal true, result.failed_due_to_deadlock?
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "returns passed result for passing test" do
|
5
|
+
work_unit = DeepTest::Test::WorkUnit.new TestFactory.passing_test
|
6
|
+
assert_equal true, work_unit.run.passed?
|
7
|
+
end
|
8
|
+
|
9
|
+
test "returns failed result for failing test" do
|
10
|
+
work_unit = DeepTest::Test::WorkUnit.new TestFactory.failing_test
|
11
|
+
assert_equal false, work_unit.run.passed?
|
12
|
+
end
|
13
|
+
|
14
|
+
test "returns result with identifier of test name" do
|
15
|
+
test = TestFactory.passing_test
|
16
|
+
work_unit = DeepTest::Test::WorkUnit.new test
|
17
|
+
assert_equal test.name, work_unit.run.identifier
|
18
|
+
end
|
19
|
+
|
20
|
+
test "capturing stdout" do
|
21
|
+
work_unit = DeepTest::Test::WorkUnit.new TestFactory.passing_test_with_stdout
|
22
|
+
assert_equal "message printed to stdout", work_unit.run.output
|
23
|
+
end
|
24
|
+
|
25
|
+
test "retry on deadlock" do
|
26
|
+
work_unit = DeepTest::Test::WorkUnit.new TestFactory.deadlock_once_test
|
27
|
+
result = work_unit.run
|
28
|
+
assert_equal 0, result.error_count
|
29
|
+
assert_equal 0, result.failure_count
|
30
|
+
assert_equal 1, result.assertion_count
|
31
|
+
end
|
32
|
+
|
33
|
+
test "skip on deadlock twice" do
|
34
|
+
work_unit = DeepTest::Test::WorkUnit.new TestFactory.deadlock_always_test
|
35
|
+
result = work_unit.run
|
36
|
+
assert_equal 0, result.error_count
|
37
|
+
assert_equal 0, result.failure_count
|
38
|
+
assert_equal 0, result.assertion_count
|
39
|
+
end
|
40
|
+
|
41
|
+
test "set test_name as identifier on deadlock" do
|
42
|
+
test = TestFactory.deadlock_always_test
|
43
|
+
work_unit = DeepTest::Test::WorkUnit.new test
|
44
|
+
assert_equal test.name, work_unit.run.identifier
|
45
|
+
end
|
46
|
+
|
47
|
+
test "equality is based on test_case" do
|
48
|
+
test_case_1 = TestFactory.passing_test
|
49
|
+
test_case_2 = TestFactory.failing_test
|
50
|
+
assert_equal DeepTest::Test::WorkUnit.new(test_case_1),
|
51
|
+
DeepTest::Test::WorkUnit.new(test_case_1)
|
52
|
+
|
53
|
+
assert_not_equal DeepTest::Test::WorkUnit.new(test_case_1),
|
54
|
+
DeepTest::Test::WorkUnit.new(test_case_2)
|
55
|
+
end
|
56
|
+
|
57
|
+
test "to_s is delegated to test case" do
|
58
|
+
test_case = TestFactory.passing_test
|
59
|
+
assert_equal test_case.to_s, DeepTest::Test::WorkUnit.new(test_case).to_s
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "should support setting timeout_in_seconds" do
|
5
|
+
t = DeepTest::TestTask.new :deep_test do |t|
|
6
|
+
t.stubs(:desc)
|
7
|
+
t.stubs(:task)
|
8
|
+
t.timeout_in_seconds = 20
|
9
|
+
end
|
10
|
+
assert_equal 20, t.instance_variable_get(:@options).timeout_in_seconds
|
11
|
+
assert_equal 20, t.timeout_in_seconds
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should support setting distributed_server" do
|
15
|
+
t = DeepTest::TestTask.new :deep_test do |t|
|
16
|
+
t.stubs(:desc)
|
17
|
+
t.stubs(:task)
|
18
|
+
t.distributed_server = "uri"
|
19
|
+
end
|
20
|
+
assert_equal "uri", t.instance_variable_get(:@options).distributed_server
|
21
|
+
assert_equal "uri", t.distributed_server
|
22
|
+
end
|
23
|
+
|
24
|
+
test "should support worker_listener" do
|
25
|
+
t = DeepTest::TestTask.new :deep_test do |t|
|
26
|
+
t.stubs(:desc)
|
27
|
+
t.stubs(:task)
|
28
|
+
t.worker_listener = "A"
|
29
|
+
end
|
30
|
+
assert_equal "A", t.instance_variable_get(:@options).worker_listener
|
31
|
+
assert_equal "A", t.worker_listener
|
32
|
+
end
|
33
|
+
|
34
|
+
test "should support server_port" do
|
35
|
+
t = DeepTest::TestTask.new :deep_test do |t|
|
36
|
+
t.stubs(:desc)
|
37
|
+
t.stubs(:task)
|
38
|
+
t.server_port = 10
|
39
|
+
end
|
40
|
+
assert_equal 10, t.instance_variable_get(:@options).server_port
|
41
|
+
assert_equal 10, t.server_port
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "running? is true if sending kill(0, pid) does not fail" do
|
5
|
+
warlock = DeepTest::Warlock.new
|
6
|
+
Process.expects(:kill).with(0, :pid)
|
7
|
+
assert_equal true, warlock.running?(:pid)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "running? is false if Process.kill(0, pid) raises Errno::ESRCH" do
|
11
|
+
warlock = DeepTest::Warlock.new
|
12
|
+
Process.stubs(:kill).raises(Errno::ESRCH)
|
13
|
+
assert_equal false, warlock.running?(:pid)
|
14
|
+
end
|
15
|
+
|
16
|
+
test "running? is true if Process.kill raises Exception" do
|
17
|
+
warlock = DeepTest::Warlock.new
|
18
|
+
Process.stubs(:kill).raises(Exception)
|
19
|
+
assert_equal true, warlock.running?(:pid)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "demon_count is 0 initially" do
|
23
|
+
assert_equal 0, DeepTest::Warlock.new.demon_count
|
24
|
+
end
|
25
|
+
|
26
|
+
test "add_demon increases demon_count by 1" do
|
27
|
+
warlock = DeepTest::Warlock.new
|
28
|
+
warlock.send(:add_demon, "name", 1)
|
29
|
+
assert_equal 1, warlock.demon_count
|
30
|
+
end
|
31
|
+
|
32
|
+
test "remove_demon increases demon_count by 1" do
|
33
|
+
warlock = DeepTest::Warlock.new
|
34
|
+
warlock.send(:add_demon, "name", 1)
|
35
|
+
warlock.send(:remove_demon, "name", 1)
|
36
|
+
assert_equal 0, warlock.demon_count
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,94 @@
|
|
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_work DeepTest::Test::WorkUnit.new(TestFactory.passing_test)
|
7
|
+
|
8
|
+
DeepTest::Worker.new(0, blackboard,stub_everything).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_work DeepTest::Test::WorkUnit.new(TestFactory.passing_test)
|
16
|
+
blackboard.write_work DeepTest::Test::WorkUnit.new(TestFactory.failing_test)
|
17
|
+
|
18
|
+
DeepTest::Worker.new(0, blackboard, stub_everything).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 "notifies listener that it is starting" do
|
28
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
29
|
+
listener = stub_everything
|
30
|
+
worker = DeepTest::Worker.new(0, blackboard, listener)
|
31
|
+
listener.expects(:starting).with(worker)
|
32
|
+
worker.run
|
33
|
+
end
|
34
|
+
|
35
|
+
test "notifies listener that it is about to do work" do
|
36
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
37
|
+
work_unit = DeepTest::Test::WorkUnit.new(TestFactory.passing_test)
|
38
|
+
blackboard.write_work work_unit
|
39
|
+
listener = stub_everything
|
40
|
+
worker = DeepTest::Worker.new(0, blackboard, listener)
|
41
|
+
listener.expects(:starting_work).with(worker, work_unit)
|
42
|
+
worker.run
|
43
|
+
end
|
44
|
+
|
45
|
+
test "notifies listener that it has done work" do
|
46
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
47
|
+
work_unit = mock(:run => :result)
|
48
|
+
blackboard.write_work work_unit
|
49
|
+
listener = stub_everything
|
50
|
+
worker = DeepTest::Worker.new(0, blackboard, listener)
|
51
|
+
listener.expects(:finished_work).with(worker, work_unit, :result)
|
52
|
+
worker.run
|
53
|
+
end
|
54
|
+
|
55
|
+
test "exception raised by work unit gives in Worker::Error" do
|
56
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
57
|
+
work_unit = mock
|
58
|
+
work_unit.expects(:run).raises(exception = RuntimeError.new)
|
59
|
+
blackboard.write_work work_unit
|
60
|
+
|
61
|
+
DeepTest::Worker.new(0, blackboard, stub_everything).run
|
62
|
+
|
63
|
+
assert_equal DeepTest::Worker::Error.new(work_unit, exception),
|
64
|
+
blackboard.take_result
|
65
|
+
end
|
66
|
+
|
67
|
+
test "requests work until it finds some" do
|
68
|
+
blackboard = mock
|
69
|
+
blackboard.expects(:take_work).times(3).
|
70
|
+
raises(DeepTest::Server::NoWorkUnitsAvailableError).
|
71
|
+
returns(work_unit = mock(:run => nil)).
|
72
|
+
returns(nil)
|
73
|
+
|
74
|
+
blackboard.expects(:write_result)
|
75
|
+
|
76
|
+
DeepTest::Worker.new(0, blackboard, stub_everything).run
|
77
|
+
end
|
78
|
+
|
79
|
+
test "finishes running when no more work units are remaining" do
|
80
|
+
blackboard = mock
|
81
|
+
blackboard.expects(:take_work).
|
82
|
+
raises(DeepTest::Server::NoWorkUnitsRemainingError)
|
83
|
+
|
84
|
+
DeepTest::Worker.new(0, blackboard, stub_everything).run
|
85
|
+
end
|
86
|
+
|
87
|
+
test "number is available to indentify worker" do
|
88
|
+
assert_equal 1, DeepTest::Worker.new(1, nil, nil).number
|
89
|
+
end
|
90
|
+
|
91
|
+
test "does not fork from rake" do
|
92
|
+
assert !defined?($rakefile)
|
93
|
+
end
|
94
|
+
end
|