DTR 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class OriginalTestReportsTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @reports = DTR::OriginalTestReports.new
7
+ end
8
+
9
+ def test_summary_of_report
10
+ assert_equal '.', @reports.summary_of(create_report(1, 1, 0, 0))
11
+ assert_equal '...', @reports.summary_of(create_report(3, 3, 0, 0))
12
+ assert_equal 'F', @reports.summary_of(create_report(1, 10, 1, 0))
13
+ assert_equal 'E', @reports.summary_of(create_report(1, 15, 0, 1))
14
+ assert_equal '.FFE', @reports.summary_of(create_report(4, 10, 2, 1))
15
+ end
16
+
17
+ def test_failures_and_errors
18
+ expected = %{ 1) Failure:
19
+ test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
20
+ <false> is not true.
21
+ }
22
+ @reports.summary_of(create_a_failed_report)
23
+ assert_equal(expected, @reports.failures_and_errors)
24
+
25
+ expected = %{ 1) Failure:
26
+ test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
27
+ <false> is not true.
28
+
29
+ 2) Failure:
30
+ test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
31
+ <false> is not true.
32
+ }
33
+ @reports.summary_of(create_a_failed_report)
34
+ assert_equal(expected, @reports.failures_and_errors)
35
+
36
+ expected = %{ 1) Error:
37
+ test_error(AnErrorTestCase):
38
+ RuntimeError: error
39
+ an_error_test_case.rb:4:in `test_error'
40
+
41
+ 2) Failure:
42
+ test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
43
+ <false> is not true.
44
+
45
+ 3) Failure:
46
+ test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
47
+ <false> is not true.
48
+ }
49
+ @reports.summary_of(create_an_error_report)
50
+ assert_equal(expected, @reports.failures_and_errors)
51
+ end
52
+
53
+ def create_report(*test_summary)
54
+ DTR::TestReport.new('test_file_name', {:name => 'client name', :exit_code => 0}, *test_summary)
55
+ end
56
+
57
+ def create_a_failed_report
58
+ stdout = %{
59
+ thought-workers-computer:~/dtr/testdata thoughtworker$ ruby a_failed_test_case.rb
60
+ Loaded suite a_failed_test_case
61
+ Started
62
+ F
63
+ Finished in 0.014801 seconds.
64
+
65
+ 1) Failure:
66
+ test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
67
+ <false> is not true.
68
+
69
+ 1 tests, 1 assertions, 1 failures, 0 errors
70
+ }
71
+ DTR::TestReport.new('a_failed_test_case.rb', {:name => 'client name', :exit_code => 0, :stdout => stdout}, 1, 1, 1, 0)
72
+ end
73
+
74
+ def create_an_error_report
75
+ stdout = %{
76
+ thought-workers-computer:~/dtr/testdata thoughtworker$ ruby an_error_test_case.rb
77
+ Loaded suite an_error_test_case
78
+ Started
79
+ E
80
+ Finished in 0.000483 seconds.
81
+
82
+ 1) Error:
83
+ test_error(AnErrorTestCase):
84
+ RuntimeError: error
85
+ an_error_test_case.rb:4:in `test_error'
86
+
87
+ 1 tests, 0 assertions, 0 failures, 1 errors
88
+ }
89
+ DTR::TestReport.new('an_error_test_case.rb', {:name => 'client name', :exit_code => 0, :stdout => stdout}, 1, 1, 0, 1)
90
+ end
91
+ end
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+
4
+ class RubyExtTest < Test::Unit::TestCase
5
+ def test_array_to_acl_list
6
+ assert_equal %w(allow localhost allow 127.0.0.1), [].to_acl_list
7
+ assert_equal %w(allow localhost allow 127.0.0.1).sort, ['druby://localhost:8888', 'sldjf'].to_acl_list.sort
8
+ assert_equal %w(allow localhost allow 127.0.0.1).sort, ['druby://127.0.0.1'].to_acl_list.sort
9
+ assert_equal %w(allow localhost allow 127.0.0.1 allow 192.168.0.111).sort, ['druby://192.168.0.111:3344'].to_acl_list.sort
10
+ assert_equal %w(allow localhost allow 127.0.0.1 allow 192.168.0.111 allow 182.1.1.1).sort, ['druby://192.168.0.111:3344', 'druby://182.1.1.1'].to_acl_list.sort
11
+ end
12
+ end
13
+
@@ -0,0 +1,56 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+
4
+ class RubyRunnerTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @report = nil
8
+ @executed_cmd = nil
9
+ @executed_time = 0
10
+ @report_updated = true
11
+ @test_case_1 = File.dirname(__FILE__) + '/../testdata/a_test_case.rb'
12
+ @runner = DTR::RubyRunner.new
13
+ end
14
+
15
+ def test_should_not_run_test_file_not_exists
16
+ @runner.run self, self, ['test_file_not_exists.rb'], 'signature'
17
+ assert_nil @executed_cmd
18
+ assert_nil @report
19
+ end
20
+
21
+ def test_should_not_continue_to_run_tests_after_updated_report_failed
22
+ @report_updated = false
23
+ @runner.run self, self, [@test_case_1, File.dirname(__FILE__) + '/../testdata/a_test_case2.rb'], 'signature'
24
+ assert_equal 1, @executed_time
25
+ end
26
+
27
+ def test_should_not_run_test_file_if_server_has_its_report
28
+ reports[@test_case_1] = 'report'
29
+ @runner.run self, self, [@test_case_1], 'signature'
30
+ assert_equal 0, @executed_time
31
+ assert_nil @report
32
+ end
33
+
34
+ def test_parse_stdout
35
+ assert_equal [2, 5, 1, 1], @runner.parse(%{
36
+ 1 tests, 1 assertions, 0 failures, 0 errors
37
+ 2 tests, 5 assertions, 1 failures, 1 errors
38
+ [[TestCase finished]]
39
+ })
40
+ end
41
+
42
+ def update(signature, report)
43
+ @report = report
44
+ @report_updated
45
+ end
46
+
47
+ def reports
48
+ @reports ||= {}
49
+ end
50
+
51
+ def execute(cmd)
52
+ @executed_time += 1
53
+ @executed_cmd = cmd
54
+ {:client_name => 'client name', :stdout => %{Finished in 1.1 seconds. \n4 tests, 2 assertions, 1 failures, 2 errors}, :stderr => 'outputs[:stderr]', :exit_code => 0}
55
+ end
56
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'test/unit'
4
+
5
+ #require 'logger'
6
+ #def logger
7
+ # logger = Logger.new STDOUT
8
+ # logger.level = Logger::DEBUG
9
+ # logger
10
+ #end
11
+
12
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
13
+ require 'dtr'
14
+
15
+ Thread.new do
16
+ Dir.chdir(File.dirname(__FILE__) + '/../testdata') do
17
+ DTROPTIONS[:setup] = 'rake setup'
18
+ DTR.start_client_server
19
+ end
20
+ end.join(1)
21
+
22
+ DTROPTIONS[:wait_a_moment] = false
23
+
24
+ class ScenarioSetupAndRunTestsSimply < Test::Unit::TestCase
25
+
26
+ def test_run_success
27
+ assert DTR.run(['a_test_case.rb', 'a_test_case2.rb'], ['druby://localhost:3344'])
28
+ end
29
+
30
+ def test_run_failed
31
+ assert !DTR.run(['a_test_case.rb', 'an_error_test_case.rb', 'a_test_case2.rb'], ['druby://localhost:3344'])
32
+ end
33
+
34
+ def test_run_setup_and_tests
35
+ assert DTR.run(['test_case_created_by_setup.rb'], ['druby://localhost:3344'], :run_setup_before_start => true)
36
+ ensure
37
+ File.delete 'test_case_created_by_setup.rb' if File.exist?('test_case_created_by_setup.rb')
38
+ end
39
+
40
+ def test_should_crash_when_there_is_client_cant_be_connected
41
+ assert DTR.run(['a_test_case.rb', 'a_test_case2.rb'], ['druby://localhost:5555', 'druby://localhost:3344'])
42
+ end
43
+
44
+ def test_should_failed_when_turn_on_option_and_there_is_no_client_alive
45
+ DTROPTIONS[:raise_on_no_alive_client] = true
46
+ assert !DTR.run(['a_test_case.rb'], ['druby://localhost:2345'])
47
+ end
48
+ end
49
+
50
+
51
+
@@ -0,0 +1,39 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ServerTest < Test::Unit::TestCase
4
+ def setup
5
+ @server = DTR::Server.new
6
+ end
7
+
8
+ def test_available_clients_should_not_contain_clients_not_idle
9
+ @server.add_client client_idling
10
+ @server.add_client client_not_idling
11
+
12
+ assert_equal [client_idling], @server.available_clients
13
+ end
14
+
15
+ def test_available_clients_should_contain_clients_connecting_self
16
+ client_connecting = OpenStruct.new :idle? => true, :server_signature => @server.server_signature, :name => 'client 1'
17
+ client_not_connecting = OpenStruct.new :idle? => true, :server_signature => DTR::Server.new.server_signature, :name => 'client 2'
18
+ @server.add_client client_connecting
19
+ @server.add_client client_not_connecting
20
+
21
+ assert_equal [client_connecting], @server.available_clients
22
+ end
23
+
24
+ def test_should_reset_client_setup_log_when_add_client
25
+ @server.add_client client_idling
26
+ @server.client_setup_logs[client_idling.name] = 'report'
27
+ @server.add_client client_idling
28
+ assert_nil @server.client_setup_logs[client_idling.name]
29
+ end
30
+
31
+ def client_idling
32
+ OpenStruct.new :idle? => true, :server_signature => @server.server_signature, :name => 'client idling'
33
+ end
34
+
35
+ def client_not_idling
36
+ OpenStruct.new :idle? => false, :server_signature => @server.server_signature, :name => 'client not idling'
37
+ end
38
+ end
39
+
@@ -0,0 +1,108 @@
1
+ require 'test/unit'
2
+ require 'fileutils'
3
+ require 'ostruct'
4
+
5
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
6
+ require 'dtr'
7
+
8
+ FileUtils.makedirs DTROPTIONS[:tmp_dir]
9
+ DTROPTIONS.merge!({:client_name => "dtr client", :setup => "echo \"setup_dtr_client\"", :wait_a_moment => false})
10
+
11
+ class NoResponseClient
12
+ attr_reader :report_signature
13
+
14
+ def self.server=(server)
15
+ @@server = server
16
+ end
17
+
18
+ def name
19
+ 'test client'
20
+ end
21
+
22
+ def server_signature
23
+ @@server.server_signature
24
+ end
25
+
26
+ def idle?
27
+ (@executing_test_files ||= nil).nil?
28
+ end
29
+
30
+ def setup(signature)
31
+ @log = log + 'setup ' + signature
32
+ @report_signature = signature
33
+ end
34
+
35
+ def run(runner_name, test_files, signature)
36
+ @report_signature = signature
37
+ raise 'I am busy, should not ask me do anymore' unless idle?
38
+ @executing_test_files = test_files
39
+ end
40
+
41
+ def log
42
+ @log ||= ''
43
+ end
44
+ end
45
+
46
+ module Test
47
+ module Unit
48
+ class TestCase
49
+ def assert_false(o)
50
+ assert !o
51
+ end
52
+
53
+ def new_successful_test_file
54
+ new_test_file do |file, num|
55
+ file.syswrite(%{
56
+ require 'test/unit'
57
+ class TestFile#{num} < Test::Unit::TestCase
58
+ def test_succeeded
59
+ assert true
60
+ end
61
+ end
62
+ })
63
+ end
64
+ end
65
+
66
+ def new_failed_test_file
67
+ new_test_file do |file, num|
68
+ file.syswrite(%{
69
+ require 'test/unit'
70
+ class TestFile#{num} < Test::Unit::TestCase
71
+ def test_failed
72
+ assert false
73
+ end
74
+ end
75
+ })
76
+ end
77
+ end
78
+
79
+ def new_error_test_file
80
+ new_test_file do |file, num|
81
+ file.syswrite(%{
82
+ require 'test/unit'
83
+ class TestFile#{num} < Test::Unit::TestCase
84
+ def test_error
85
+ raise 'error'
86
+ end
87
+
88
+ def test_runtime_error
89
+ should.raise.runtime.error
90
+ end
91
+ end
92
+ })
93
+ end
94
+ end
95
+
96
+ def new_test_file
97
+ @test_file_num ||= 0
98
+ @test_file_num += 1
99
+ file_name = "#{DTROPTIONS[:tmp_dir]}/test_file#{@test_file_num}.rb"
100
+ File.open(file_name, 'w') do |file|
101
+ yield file, @test_file_num
102
+ end
103
+
104
+ file_name
105
+ end
106
+ end
107
+ end
108
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: DTR
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-09-19 00:00:00 +08:00
8
+ summary: DTR is a distributed test runner to run tests on distributed computers for decreasing build time.
9
+ require_paths:
10
+ - lib
11
+ email: swing1979@gmail.com
12
+ homepage: http://dtr.rubyforge.org
13
+ rubyforge_project: dtr
14
+ description:
15
+ autorequire:
16
+ default_executable: dtr
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Li Xiao
31
+ files:
32
+ - install.rb
33
+ - bin
34
+ - CHANGES
35
+ - doc
36
+ - html
37
+ - lib
38
+ - LICENSE.TXT
39
+ - Rakefile
40
+ - README
41
+ - show_process_exit_code.bat
42
+ - test
43
+ - testdata
44
+ - tmp
45
+ - TODO
46
+ - bin/dtr
47
+ - lib/dtr/base.rb
48
+ - lib/dtr/command_line.rb
49
+ - lib/dtr/drb_dtr.rb
50
+ - lib/dtr/ruby_ext.rb
51
+ - lib/dtr.rb
52
+ - test/average_packer_test.rb
53
+ - test/base_test.rb
54
+ - test/original_test_reports_test.rb
55
+ - test/ruby_ext_test.rb
56
+ - test/ruby_runner_test.rb
57
+ - test/scenario_setup_and_run_tests_simply.rb
58
+ - test/server_test.rb
59
+ - test/test_helper.rb
60
+ - doc/jamis.rb
61
+ test_files: []
62
+
63
+ rdoc_options: []
64
+
65
+ extra_rdoc_files: []
66
+
67
+ executables:
68
+ - dtr
69
+ extensions: []
70
+
71
+ requirements: []
72
+
73
+ dependencies:
74
+ - !ruby/object:Gem::Dependency
75
+ name: progressbar
76
+ version_requirement:
77
+ version_requirements: !ruby/object:Gem::Version::Requirement
78
+ requirements:
79
+ - - ">"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.0.2
82
+ version: