jstorimer-deep-test 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/README.rdoc +70 -41
- data/Rakefile +104 -32
- data/TODO +2 -2
- data/VERSION +1 -1
- data/bin/deep_test +15 -0
- data/jstorimer-deep-test-0.1.0.gem +0 -0
- data/jstorimer-deep-test.gemspec +1425 -0
- data/lib/deep_test.rb +40 -28
- data/lib/deep_test/database/mysql_setup_listener.rb +12 -12
- data/lib/deep_test/database/setup_listener.rb +23 -23
- data/lib/deep_test/distributed/dispatch_controller.rb +10 -17
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -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 +82 -0
- data/lib/deep_test/distributed/rsync.rb +12 -25
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +78 -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/listener_list.rb +1 -1
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +2 -17
- data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
- 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_listener.rb → null_worker_listener.rb} +14 -14
- data/lib/deep_test/option.rb +60 -0
- data/lib/deep_test/options.rb +42 -45
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +1 -3
- data/lib/deep_test/result_reader.rb +6 -10
- data/lib/deep_test/rspec_detector.rb +1 -1
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +1 -5
- data/lib/deep_test/spec/extensions/example_methods.rb +1 -7
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +2 -3
- data/lib/deep_test/spec/runner.rb +17 -32
- data/lib/deep_test/spec/work_result.rb +0 -2
- data/lib/deep_test/test/runner.rb +2 -2
- data/lib/deep_test/test/supervised_test_suite.rb +10 -9
- data/lib/deep_test/test/work_result.rb +0 -1
- data/lib/deep_test/test_task.rb +1 -1
- data/lib/deep_test/ui/console.rb +11 -9
- data/lib/deep_test/warlock.rb +25 -37
- data/lib/deep_test/worker.rb +57 -0
- data/sample_rails_project/deep_test.rb +0 -4
- data/sample_rails_project/lib/{foreign_host_agent_simulation_listener.rb → foreign_host_worker_simulation_listener.rb} +4 -6
- data/sample_rails_project/lib/tasks/deep_test.rake +4 -13
- 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/spec/deep_test/option_spec.rb +33 -0
- data/spec/deep_test/options_spec.rb +59 -80
- data/spec/deep_test/spec/extensions/example_methods_spec.rb +4 -5
- data/spec/deep_test/spec/extensions/spec_task_spec.rb +6 -4
- data/spec/deep_test/spec/runner_spec.rb +32 -59
- data/spec/spec_helper.rb +6 -14
- data/spec/thread_worker.rb +25 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +9 -13
- data/test/deep_test/distributed/dispatch_controller_test.rb +177 -130
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +34 -38
- 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 +99 -0
- data/test/deep_test/distributed/rsync_test.rb +62 -42
- 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/listener_list_test.rb +15 -17
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +7 -34
- data/test/deep_test/marshallable_exception_wrapper_test.rb +29 -31
- 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 +95 -95
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +36 -38
- data/test/deep_test/test/runner_test.rb +3 -7
- data/test/deep_test/test/supervised_test_suite_test.rb +61 -89
- data/test/deep_test/test/work_result_test.rb +76 -80
- data/test/deep_test/test/work_unit_test.rb +51 -53
- data/test/deep_test/test_task_test.rb +38 -10
- data/test/deep_test/ui/console_test.rb +4 -8
- data/test/deep_test/warlock_test.rb +31 -33
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/{negative_acceptance_tests/failing_test.rb → test/failing.rb} +1 -3
- data/{infrastructure → test}/fake_deadlock_error.rb +0 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/{infrastructure → test}/test_factory.rb +0 -0
- data/test/test_helper.rb +5 -20
- data/test/test_task_test.rb +57 -60
- metadata +78 -87
- data/infrastructure/dynamic_teardown.rb +0 -22
- data/infrastructure/load.rb +0 -11
- data/infrastructure/test_central_command.rb +0 -15
- data/infrastructure/test_exception.rb +0 -7
- data/infrastructure/test_logger.rb +0 -11
- data/infrastructure/test_operator.rb +0 -15
- data/infrastructure/test_result.rb +0 -15
- data/infrastructure/thread_agent.rb +0 -21
- data/infrastructure/timewarp/Rakefile +0 -14
- data/infrastructure/timewarp/lib/timewarp.rb +0 -21
- data/infrastructure/timewarp/test/timewarp_test.rb +0 -45
- data/lib/deep_test/agent.rb +0 -108
- data/lib/deep_test/central_command.rb +0 -165
- data/lib/deep_test/cpu_info.rb +0 -22
- data/lib/deep_test/demon.rb +0 -25
- data/lib/deep_test/distributed/beachhead.rb +0 -104
- data/lib/deep_test/distributed/establish_beachhead.rb +0 -19
- data/lib/deep_test/distributed/landing_fleet.rb +0 -30
- data/lib/deep_test/distributed/landing_ship.rb +0 -60
- data/lib/deep_test/distributed/remote_deployment.rb +0 -56
- data/lib/deep_test/distributed/shell_environment.rb +0 -50
- data/lib/deep_test/distributed/ssh_client_connection_info.rb +0 -14
- data/lib/deep_test/failure_message.rb +0 -19
- data/lib/deep_test/lib_root.rb +0 -4
- data/lib/deep_test/local_deployment.rb +0 -46
- data/lib/deep_test/main.rb +0 -41
- data/lib/deep_test/metrics/data.rb +0 -34
- data/lib/deep_test/metrics/measurement.rb +0 -39
- data/lib/deep_test/proxy_io.rb +0 -77
- data/lib/deep_test/test/run_test_suite.rb +0 -5
- data/lib/telegraph.rb +0 -29
- data/lib/telegraph/ack_sequence.rb +0 -14
- data/lib/telegraph/logging.rb +0 -20
- data/lib/telegraph/message.rb +0 -39
- data/lib/telegraph/operator.rb +0 -47
- data/lib/telegraph/switchboard.rb +0 -57
- data/lib/telegraph/wire.rb +0 -73
- data/negative_acceptance_tests/dying_spec.rb +0 -13
- data/negative_acceptance_tests/dying_test.rb +0 -13
- data/negative_acceptance_tests/failing_spec.rb +0 -9
- data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +0 -16
- data/negative_acceptance_tests/passing_spec.rb +0 -10
- data/negative_acceptance_tests/passing_test.rb +0 -12
- data/negative_acceptance_tests/tasks.rake +0 -87
- data/negative_acceptance_tests/tests.rb +0 -60
- data/test/deep_test/agent_test.rb +0 -175
- data/test/deep_test/central_command_test.rb +0 -147
- data/test/deep_test/cpu_info_test.rb +0 -33
- data/test/deep_test/demon_test.rb +0 -23
- data/test/deep_test/distributed/beachhead_test.rb +0 -67
- data/test/deep_test/distributed/landing_fleet_test.rb +0 -55
- data/test/deep_test/distributed/landing_ship_test.rb +0 -48
- data/test/deep_test/distributed/remote_deployment_test.rb +0 -134
- data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +0 -1
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +0 -1
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +0 -1
- data/test/deep_test/distributed/shell_environment_test.rb +0 -108
- data/test/deep_test/distributed/ssh_client_connection_info_test.rb +0 -34
- data/test/deep_test/local_deployment_test.rb +0 -19
- data/test/deep_test/main_test.rb +0 -12
- data/test/deep_test/metrics/data_test.rb +0 -22
- data/test/deep_test/metrics/measurement_test.rb +0 -18
- data/test/deep_test/proxy_io_test.rb +0 -104
@@ -1,13 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
assert_nothing_raised do
|
8
|
-
Console.new(:options).dispatch_finished(:method_name)
|
9
|
-
end
|
10
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "dispatch_finished doesn't fail if spinner is nil" do
|
5
|
+
assert_nothing_raised do
|
6
|
+
DeepTest::UI::Console.new(:options).dispatch_finished(:method_name)
|
11
7
|
end
|
12
8
|
end
|
13
9
|
end
|
@@ -1,40 +1,38 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
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
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
test "demon_count is 0 initially" do
|
23
|
+
assert_equal 0, DeepTest::Warlock.new.demon_count
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
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
|
39
37
|
end
|
40
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
|
data/test/failing.rake
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rake'
|
2
|
+
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
|
3
|
+
require "deep_test"
|
4
|
+
require "deep_test/rake_tasks"
|
5
|
+
|
6
|
+
task :default => %w[deep_test_failing]
|
7
|
+
|
8
|
+
DeepTest::TestTask.new :deep_test_failing do |t|
|
9
|
+
t.number_of_workers = 1
|
10
|
+
t.pattern = "test/failing.rb"
|
11
|
+
end
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class SimpleTestBlackboard
|
3
|
+
attr_accessor :debug, :simulate_result_overdue_error
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@work_units = []
|
7
|
+
@test_results = []
|
8
|
+
@semaphore = Mutex.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def take_result
|
12
|
+
raise DeepTest::Server::ResultOverdueError if @simulate_result_overdue_error
|
13
|
+
@semaphore.synchronize do
|
14
|
+
log_and_return "take_result", @test_results.shift
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def take_work
|
19
|
+
@semaphore.synchronize do
|
20
|
+
log_and_return "take_work", @work_units.shift
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_result(result)
|
25
|
+
@semaphore.synchronize do
|
26
|
+
log_and_return "write_result", result
|
27
|
+
@test_results.push result
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def write_work(work_unit)
|
32
|
+
@semaphore.synchronize do
|
33
|
+
log_and_return "write_work", work_unit
|
34
|
+
@work_units.push work_unit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def log_and_return(message, object)
|
39
|
+
if debug && object
|
40
|
+
puts "* #{message} #{object.inspect}"
|
41
|
+
end
|
42
|
+
object
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
|
+
|
3
|
+
unit_tests do
|
4
|
+
test "a test that is put on can be taken off later" do
|
5
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
6
|
+
test_case = TestFactory.passing_test
|
7
|
+
blackboard.write_work test_case
|
8
|
+
assert_equal test_case, blackboard.take_work
|
9
|
+
end
|
10
|
+
|
11
|
+
test "taking a test when all have been taken returns nil" do
|
12
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
13
|
+
test_case = TestFactory.passing_test
|
14
|
+
blackboard.write_work test_case
|
15
|
+
blackboard.take_work
|
16
|
+
assert_nil blackboard.take_work
|
17
|
+
end
|
18
|
+
|
19
|
+
test "a result that is put on can be taken off later" do
|
20
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
21
|
+
result = TestFactory.passed_result
|
22
|
+
blackboard.write_result result
|
23
|
+
assert_equal result, blackboard.take_result
|
24
|
+
end
|
25
|
+
|
26
|
+
test "taking a result when all have been taken returns nil" do
|
27
|
+
blackboard = DeepTest::SimpleTestBlackboard.new
|
28
|
+
result = TestFactory.passed_result
|
29
|
+
blackboard.write_result result
|
30
|
+
blackboard.take_result
|
31
|
+
assert_nil blackboard.take_result
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
data/test/test_helper.rb
CHANGED
@@ -2,29 +2,14 @@ require 'rubygems'
|
|
2
2
|
require 'test/unit'
|
3
3
|
require 'dust'
|
4
4
|
require 'mocha'
|
5
|
-
require 'set'
|
6
|
-
|
7
5
|
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
8
6
|
require "deep_test"
|
7
|
+
require 'set'
|
9
8
|
|
10
|
-
require File.dirname(__FILE__) + "
|
9
|
+
require File.dirname(__FILE__) + "/fake_deadlock_error"
|
10
|
+
require File.dirname(__FILE__) + "/simple_test_blackboard"
|
11
|
+
require File.dirname(__FILE__) + "/test_factory"
|
12
|
+
require File.dirname(__FILE__) + "/../spec/thread_worker"
|
11
13
|
|
12
14
|
class SomeCustomException < RuntimeError
|
13
15
|
end
|
14
|
-
|
15
|
-
class Test::Unit::TestCase
|
16
|
-
def setup
|
17
|
-
@old_logger = DeepTest.logger
|
18
|
-
DeepTest.logger = TestLogger.new
|
19
|
-
DynamicTeardown.setup
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
DeepTest.logger = @old_logger if @old_logger
|
24
|
-
DynamicTeardown.teardown
|
25
|
-
end
|
26
|
-
|
27
|
-
def at(time, &block)
|
28
|
-
Timewarp.freeze(time, &block)
|
29
|
-
end
|
30
|
-
end
|
data/test/test_task_test.rb
CHANGED
@@ -1,75 +1,72 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
TestTask.new :my_task_name do
|
9
|
-
end
|
3
|
+
unit_tests do
|
4
|
+
test "defines a rake task with the name passed to the constructor" do
|
5
|
+
DeepTest::TestTask.any_instance.stubs(:desc)
|
6
|
+
DeepTest::TestTask.any_instance.expects(:task).with(:my_task_name)
|
7
|
+
DeepTest::TestTask.new :my_task_name do
|
10
8
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
assert_equal pattern, task.pattern[-pattern.size..-1]
|
9
|
+
end
|
10
|
+
|
11
|
+
test "setting pattern" do
|
12
|
+
pattern = "test/**/x*_test.rb"
|
13
|
+
task = DeepTest::TestTask.new do |t|
|
14
|
+
t.stubs(:define)
|
15
|
+
t.pattern = pattern
|
19
16
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
assert_equal pattern, task.pattern[-pattern.size..-1]
|
18
|
+
end
|
19
|
+
|
20
|
+
test "default pattern is test/**/*_test.rb" do
|
21
|
+
task = DeepTest::TestTask.new do |t|
|
22
|
+
t.stubs(:define)
|
26
23
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
assert_equal "test/**/*_test.rb", task.pattern[-"test/**/*_test.rb".size..-1]
|
25
|
+
end
|
26
|
+
|
27
|
+
test "default libs is ['lib']" do
|
28
|
+
task = DeepTest::TestTask.new do |t|
|
29
|
+
t.stubs(:define)
|
33
30
|
end
|
31
|
+
assert_equal ["lib"], task.libs
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
assert_equal ["lib", "test"], task.libs
|
34
|
+
test "can add to libs" do
|
35
|
+
task = DeepTest::TestTask.new do |t|
|
36
|
+
t.libs << "test"
|
37
|
+
t.stubs(:define)
|
41
38
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Rake::Task["deep_test"].instance_variable_get("@actions").last.call
|
39
|
+
assert_equal ["lib", "test"], task.libs
|
40
|
+
end
|
41
|
+
|
42
|
+
test "define passes the -I option to the call to ruby" do
|
43
|
+
task = DeepTest::TestTask.new do |t|
|
44
|
+
t.libs << "test"
|
49
45
|
end
|
46
|
+
task.expects(:ruby).with(includes("-Ilib:test"))
|
47
|
+
Rake::Task["deep_test"].instance_variable_get("@actions").last.call
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
task.expects(:ruby).with(Not(includes("-I")))
|
56
|
-
Rake::Task["deep_test"].instance_variable_get("@actions").last.call
|
50
|
+
test "define does not pass the -I option to the call to ruby if there are no directories to add to the load path" do
|
51
|
+
task = DeepTest::TestTask.new do |t|
|
52
|
+
t.libs = []
|
57
53
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
54
|
+
task.expects(:ruby).with(Not(includes("-I")))
|
55
|
+
Rake::Task["deep_test"].instance_variable_get("@actions").last.call
|
56
|
+
end
|
57
|
+
|
58
|
+
test "number_of_workers defaults to 2" do
|
59
|
+
task = DeepTest::TestTask.new do |t|
|
60
|
+
t.stubs(:define)
|
65
61
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
62
|
+
assert_equal 2, task.number_of_workers
|
63
|
+
end
|
64
|
+
|
65
|
+
test "number_of_workers can be set" do
|
66
|
+
task = DeepTest::TestTask.new do |t|
|
67
|
+
t.number_of_workers = 42
|
68
|
+
t.stubs(:define)
|
73
69
|
end
|
70
|
+
assert_equal 42, task.number_of_workers
|
74
71
|
end
|
75
72
|
end
|