BuildMaster 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. data/README +6 -29
  2. data/lib/buildmaster.rb +0 -2
  3. data/lib/buildmaster/ant_driver.rb +13 -12
  4. data/lib/buildmaster/build_number_file.rb +2 -12
  5. data/lib/buildmaster/buildnumber +1 -1
  6. data/lib/buildmaster/cotta.rb +4 -0
  7. data/lib/buildmaster/cotta/command_error.rb +5 -0
  8. data/lib/buildmaster/cotta/cotta.rb +35 -0
  9. data/lib/buildmaster/cotta/cotta_dir.rb +73 -0
  10. data/lib/buildmaster/cotta/cotta_file.rb +99 -0
  11. data/lib/buildmaster/cotta/file_not_found_error.rb +13 -0
  12. data/lib/buildmaster/cotta/in_memory_system.rb +160 -0
  13. data/lib/buildmaster/cotta/physical_system.rb +64 -0
  14. data/lib/buildmaster/cvs_driver.rb +5 -13
  15. data/lib/buildmaster/file_processor.rb +34 -33
  16. data/lib/buildmaster/java_manifest.rb +3 -3
  17. data/lib/buildmaster/site/site.rb +11 -22
  18. data/lib/buildmaster/site_spec.rb +15 -13
  19. data/lib/buildmaster/source_file_handler.rb +1 -1
  20. data/lib/buildmaster/svn_driver.rb +14 -20
  21. data/lib/buildmaster/{template_exception.rb → template_error.rb} +1 -1
  22. data/lib/buildmaster/template_runner.rb +2 -2
  23. data/lib/buildmaster/templatelets/attribute.rb +1 -1
  24. data/lib/buildmaster/templatelets/href.rb +1 -1
  25. data/lib/buildmaster/templatelets/text.rb +1 -1
  26. data/lib/buildmaster/templatelets/when.rb +1 -1
  27. data/lib/buildmaster/windows.rb +3 -0
  28. data/lib/buildmaster/windows/iis_driver.rb +33 -0
  29. data/lib/buildmaster/windows/sql_server_driver.rb +27 -0
  30. data/test/buildmaster/cotta/content.txt +3 -0
  31. data/test/buildmaster/cotta/cotta_specifications.rb +172 -0
  32. data/test/buildmaster/cotta/physical_system_stub.rb +85 -0
  33. data/test/buildmaster/cotta/system_file_specifications.rb +131 -0
  34. data/test/buildmaster/cotta/tc_cotta.rb +33 -0
  35. data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +23 -0
  36. data/test/buildmaster/cotta/tc_cotta_dir_physical.rb +17 -0
  37. data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +20 -0
  38. data/test/buildmaster/cotta/tc_cotta_file_physical.rb +17 -0
  39. data/test/buildmaster/cotta/tc_in_memory_system.rb +25 -0
  40. data/test/buildmaster/cotta/tc_physical_system.rb +26 -0
  41. data/test/buildmaster/manifest.mf +1 -1
  42. data/test/buildmaster/site/tc_site.rb +58 -34
  43. data/test/buildmaster/site/tc_template_builder.rb +32 -31
  44. data/test/buildmaster/tc_ant_driver.rb +11 -13
  45. data/test/buildmaster/tc_build_number_file.rb +21 -16
  46. data/test/buildmaster/tc_cvs_driver.rb +35 -37
  47. data/test/buildmaster/tc_file_processor.rb +58 -34
  48. data/test/buildmaster/tc_java_manifest.rb +37 -9
  49. data/test/buildmaster/tc_site_spec.rb +20 -15
  50. data/test/buildmaster/tc_source_file_handler.rb +4 -4
  51. data/test/buildmaster/tc_svn_driver.rb +51 -38
  52. data/test/buildmaster/tc_template_runner.rb +19 -18
  53. data/test/buildmaster/tc_tree_to_object.rb +47 -46
  54. data/test/buildmaster/tc_xtemplate.rb +52 -38
  55. data/test/buildmaster/templatelets/common_templatelet_test.rb +9 -8
  56. data/test/buildmaster/templatelets/tc_attribute.rb +26 -23
  57. data/test/buildmaster/templatelets/tc_each.rb +27 -26
  58. data/test/buildmaster/templatelets/tc_href.rb +14 -13
  59. data/test/buildmaster/templatelets/tc_include.rb +11 -4
  60. data/test/buildmaster/templatelets/tc_link.rb +18 -12
  61. data/test/buildmaster/templatelets/tc_text.rb +12 -7
  62. data/test/buildmaster/templatelets/tc_when.rb +11 -5
  63. data/test/buildmaster/windows/tc_iis_driver.rb +29 -0
  64. data/test/buildmaster/windows/tc_sql_server_driver.rb +24 -0
  65. data/test/spec_runner.rb +27 -0
  66. data/test/ts_buildmaster.rb +2 -19
  67. metadata +34 -10
  68. data/lib/buildmaster/release_control.rb +0 -22
  69. data/lib/buildmaster/shell_command.rb +0 -39
  70. data/test/buildmaster/tc_release_control.rb +0 -27
  71. data/test/buildmaster/ts_site.rb +0 -4
  72. data/test/buildmaster/ts_templatelets.rb +0 -10
@@ -1,72 +1,85 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
2
 
3
- require 'test/unit'
3
+ require 'spec'
4
4
  require 'buildmaster'
5
+ require 'buildmaster/cotta'
6
+ require 'buildmaster/cotta/in_memory_system'
5
7
 
6
8
  module BuildMaster
7
- class SvnDriverTest < Test::Unit::TestCase
8
- protected
9
- def setup
10
- super
11
- @path = File.join(File.dirname(__FILE__), "..", "..")
12
- @info = SvnInfo.new @path
9
+
10
+ context 'SVN drivers' do
11
+ setup do
12
+ @system = InMemorySystem.new
13
+ cotta = Cotta.new(@system)
14
+ @work_dir_root = cotta.dir('/workdir')
15
+ @work_dir_root.dir('.svn').file('entries').save <<CONTENT
16
+ <?xml version="1.0" encoding="utf-8"?>
17
+ <wc-entries
18
+ xmlns="svn:">
19
+ <entry
20
+ committed-rev="120"
21
+ name=""
22
+ committed-date="2006-09-05T06:50:07.932800Z"
23
+ url="svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster/trunk"
24
+ last-author="wolfdancer"
25
+ kind="dir"
26
+ uuid="ab7ff8c2-9713-0410-a269-a4b56b3120d2"
27
+ repos="svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster"
28
+ prop-time="2006-09-05T06:49:40.625000Z"
29
+ revision="120"/>
30
+ </wc-entries>
31
+ CONTENT
32
+ @info = SvnInfo.new @work_dir_root
13
33
  end
14
34
 
15
- public
16
- def test_load_info
17
- info = SvnInfo.new(@path)
18
- assert_equal(@path, info.path)
19
- assert_equal('svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster', info.repository_root)
35
+ specify 'load svn info from the .svn directory' do
36
+ info = SvnInfo.new(@work_dir_root)
37
+ info.work_dir.should_equal @work_dir_root
38
+ info.repository_root.should_equal 'svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster'
20
39
  end
21
40
 
22
- def test_load_driver
23
- svn = SvnDriver.from_path(@path)
41
+ specify 'load svn driver from the root directory' do
42
+ svn = SvnDriver.from_path(@work_dir_root)
24
43
  svn.command('info')
25
44
  end
26
45
 
27
- def test_status
46
+ specify 'svn status command' do
28
47
  log = ''
29
- svn = SvnDriver.new(@info){|command| log = command}
48
+ svn = SvnDriver.new(@info)
30
49
  svn.status
31
- assert_equal("svn status #{@path}", log)
50
+ @system.executed_commands[0].should_equal "svn status #{@work_dir_root.path}"
32
51
  end
33
52
 
34
- def test_update
53
+ specify 'svn update command' do
35
54
  log = ''
36
- svn = SvnDriver.new(@info) {|command| log = command}
55
+ svn = SvnDriver.new(@info)
37
56
  svn.update
38
- assert_equal("svn update #{@path}", log)
57
+ @system.executed_commands[0].should_equal "svn update #{@work_dir_root.path}"
39
58
  end
40
59
 
41
- def test_commit
42
- log = ''
43
- svn = SvnDriver.new(@info) {|command| log = command}
60
+ specify 'svn commit command' do
61
+ svn = SvnDriver.new(@info)
44
62
  svn.commit('message')
45
- assert_equal("svn commit #{@path} -m \"message\"", log)
63
+ @system.executed_commands[0].should_equal "svn commit #{@work_dir_root.path} -m \"message\""
46
64
  end
47
65
 
48
- def test_checkout
49
- log = ''
50
- svn = SvnDriver.new(@info) {|command| log = command}
66
+ specify 'svn check out command' do
67
+ svn = SvnDriver.new(@info)
51
68
  svn.checkout('output')
52
- assert_equal("svn checkout #{@info.repository_root}/trunk output", log)
69
+ @system.executed_commands[0].should_equal "svn checkout #{@info.repository_root}/trunk output"
53
70
  end
54
71
 
55
- def test_command
56
- log = ''
57
- svn = SvnDriver.new(@info) {|command| log = command}
72
+ specify 'svn command' do
73
+ svn = SvnDriver.new(@info)
58
74
  svn.command('info')
59
- assert_equal("svn info #{@path}", log)
75
+ @system.executed_commands[0].should_equal "svn info #{@work_dir_root.path}"
60
76
  end
61
77
 
62
- def test_tag
63
- log = ''
64
- svn = SvnDriver.new(@info) {|command| log = command}
78
+ specify 'svn tag' do
79
+ svn = SvnDriver.new(@info)
65
80
  tag = 'build_0.0.5_b3'
66
81
  svn.tag(tag)
67
- assert_equal(
68
- "svn copy #{@info.repository_root}/trunk #{@info.repository_root}/tags/#{tag} -m \"ruby buildmaster\"",
69
- log)
82
+ @system.executed_commands[0].should_equal "svn copy #{@info.repository_root}/trunk #{@info.repository_root}/tags/#{tag} -m \"ruby buildmaster\""
70
83
  end
71
84
 
72
85
  end
@@ -2,15 +2,25 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
2
 
3
3
  require 'rexml/xpath'
4
4
  require 'rexml/document'
5
- require 'test/unit'
5
+ require 'spec'
6
6
  require 'pathname'
7
7
  require 'buildmaster/template_runner'
8
8
  require 'buildmaster/source_content'
9
9
  require 'buildmaster/templatelets'
10
10
 
11
11
  module BuildMaster
12
- class TemplateRunnerTest < Test::Unit::TestCase
13
- def test_process_element_in_document
12
+ class NameTemplatelet
13
+ def initialize(logger)
14
+ @logger = logger
15
+ end
16
+
17
+ def process(target, element, current_path)
18
+ @logger.processed(target, element)
19
+ end
20
+ end
21
+
22
+ context 'TemplateRunnerTest' do
23
+ specify 'process_element_in_document' do
14
24
  target_content = <<END
15
25
  <html>
16
26
  <h1/>
@@ -39,10 +49,10 @@ END
39
49
  SourceContent.new(Pathname.new('content'), source_element))
40
50
  runner.templatelets['include'] = Include.new(self)
41
51
  runner.process
42
- assert_equal('Name One', REXML::XPath.first(REXML::Document.new(target_xml.to_s), '/html/h1/text()').value.strip)
52
+ REXML::XPath.first(REXML::Document.new(target_xml.to_s), '/html/h1/text()').value.strip.should_equal 'Name One'
43
53
  end
44
54
 
45
- def test_should_use_templatelet_based_on_name
55
+ specify 'should_use_templatelet_based_on_name' do
46
56
  output = REXML::Document.new
47
57
  template_content = <<END
48
58
  <html xmlns="http://www.w3.org/1999/xhtml"
@@ -57,10 +67,10 @@ END
57
67
  SourceContent.new(Pathname.new('content/index.textile'), REXML::Document.new))
58
68
  runner.templatelets['name'] = NameTemplatelet.new(self)
59
69
  runner.process
60
- assert_equal('p', @element_target.name)
61
- assert_equal('name', @element_processed.name)
62
- assert_equal('value', @element_processed.attributes['attribute'])
63
- assert_equal('value2', @element_processed.attributes['attribute2'])
70
+ @element_target.name.should_equal 'p'
71
+ @element_processed.name.should_equal 'name'
72
+ @element_processed.attributes['attribute'].should_equal 'value'
73
+ @element_processed.attributes['attribute2'].should_equal 'value2'
64
74
  end
65
75
 
66
76
  def processed(target, element)
@@ -69,13 +79,4 @@ END
69
79
  end
70
80
  end
71
81
 
72
- class NameTemplatelet
73
- def initialize(logger)
74
- @logger = logger
75
- end
76
-
77
- def process(target, element, current_path)
78
- @logger.processed(target, element)
79
- end
80
- end
81
82
  end
@@ -1,12 +1,34 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
2
 
3
- require 'test/unit'
3
+ require 'spec'
4
4
 
5
5
  require 'buildmaster/tree_to_object'
6
6
 
7
7
  module BuildMaster
8
- class TreeToObjectTest < Test::Unit::TestCase
9
- def test_should_populate_string_fields
8
+
9
+ class SampleObject
10
+ attr_reader :field_one, :field_two, :object_two, :array_field
11
+ attr_writer :field_one, :field_two
12
+
13
+ def initialize
14
+ @object_two = SampleTwo.new
15
+ @array_field = Array.new
16
+ end
17
+
18
+ def add_to_array_field
19
+ item = SampleTwo.new
20
+ @array_field.push(item)
21
+ return item
22
+ end
23
+ end
24
+
25
+ class SampleTwo
26
+ attr_reader :field, :index
27
+ attr_writer :field, :index
28
+ end
29
+
30
+ context 'TreeToObjectTest' do
31
+ specify 'should_populate_string_fields' do
10
32
  content = <<CONTENT
11
33
  field_one: value_one
12
34
  field_two: value_two
@@ -14,11 +36,11 @@ CONTENT
14
36
  tree = YAML.load(content)
15
37
  object = SampleObject.new
16
38
  TreeToObject.new(tree, object).convert
17
- assert_equal('value_one', object.field_one)
18
- assert_equal('value_two', object.field_two)
39
+ object.field_one.should_equal 'value_one'
40
+ object.field_two.should_equal 'value_two'
19
41
  end
20
42
 
21
- def test_should_populate_array_fields
43
+ specify 'should_populate_array_fields' do
22
44
  content = <<CONTENT
23
45
  array_field:
24
46
  - field: valueone
@@ -28,14 +50,14 @@ array_field:
28
50
  CONTENT
29
51
  object = TreeToObject.from_yaml(content, SampleObject.new)
30
52
  array = object.array_field
31
- assert_equal(2, array.size)
32
- assert_equal('valueone', array[0].field)
33
- assert_equal('1', array[0].index.to_s)
34
- assert_equal('valuetwo', array[1].field)
35
- assert_equal('2', array[1].index.to_s)
53
+ array.size.should_equal 2
54
+ array[0].field.should_equal 'valueone'
55
+ array[0].index.to_s.should_equal '1'
56
+ array[1].field.should_equal 'valuetwo'
57
+ array[1].index.to_s.should_equal '2'
36
58
  end
37
59
 
38
- def test_should_populate_instance_fields
60
+ specify 'should_populate_instance_fields' do
39
61
  content = <<CONTENT
40
62
  object_two:
41
63
  field: my_field
@@ -43,11 +65,11 @@ object_two:
43
65
  CONTENT
44
66
  object = TreeToObject.from_yaml(content, SampleObject.new)
45
67
  actual = object.object_two
46
- assert_equal('my_field', actual.field)
47
- assert_equal('5', actual.index.to_s)
68
+ actual.field.should_equal 'my_field'
69
+ actual.index.to_s.should_equal '5'
48
70
  end
49
71
 
50
- def test_should_raise_error_if_property_not_found
72
+ specify 'should_raise_error_if_property_not_found' do
51
73
  content = <<CONTENT
52
74
  not_field: value
53
75
  CONTENT
@@ -55,12 +77,12 @@ CONTENT
55
77
  object = TreeToObject.from_yaml(content, SampleObject.new)
56
78
  fail('exception should have been thrown')
57
79
  rescue PropertyMatchError => error
58
- assert_equal(true, error.message.include?('not_field'))
59
- assert_equal(true, error.message.include?('string'))
80
+ error.message.include?('not_field').should_equal true
81
+ error.message.include?('string').should_equal true
60
82
  end
61
83
  end
62
84
 
63
- def test_should_raise_error_if_sub_property_not_found
85
+ specify 'should_raise_error_if_sub_property_not_found' do
64
86
  content = <<CONTENT
65
87
  not_sub_property:
66
88
  field: value
@@ -69,12 +91,12 @@ CONTENT
69
91
  object = TreeToObject.from_yaml(content, SampleObject.new)
70
92
  fail('exception should have been thrown')
71
93
  rescue PropertyMatchError => error
72
- assert_equal(true, error.message.include?('not_sub_property'))
73
- assert_equal(true, error.message.include?('sub property'))
94
+ error.message.include?('not_sub_property').should_equal true
95
+ error.message.include?('sub property').should_equal true
74
96
  end
75
97
  end
76
98
 
77
- def test_should_raise_error_if_array_property_not_found
99
+ specify 'should_raise_error_if_array_property_not_found' do
78
100
  content = <<CONTENT
79
101
  not_array_property:
80
102
  - name: title
@@ -84,37 +106,16 @@ CONTENT
84
106
  object = TreeToObject.from_yaml(content, SampleObject.new)
85
107
  fail('exception should have been thrown')
86
108
  rescue PropertyMatchError => error
87
- assert_equal(true, error.message.include?('not_array_property'))
88
- assert_equal(true, error.message.include?('array'))
109
+ error.message.include?('not_array_property').should_equal true
110
+ error.message.include?('array').should_equal true
89
111
  end
90
112
  end
91
113
 
92
- def test_empty_content
114
+ specify 'empty_content' do
93
115
  object = TreeToObject.from_yaml('', SampleObject.new)
94
- assert_equal(nil, object.field_one)
116
+ object.field_one.should_equal nil
95
117
  end
96
118
 
97
119
  end
98
120
 
99
-
100
- class SampleObject
101
- attr_reader :field_one, :field_two, :object_two, :array_field
102
- attr_writer :field_one, :field_two
103
-
104
- def initialize
105
- @object_two = SampleTwo.new
106
- @array_field = Array.new
107
- end
108
-
109
- def add_to_array_field
110
- item = SampleTwo.new
111
- @array_field.push(item)
112
- return item
113
- end
114
- end
115
-
116
- class SampleTwo
117
- attr_reader :field, :index
118
- attr_writer :field, :index
119
- end
120
121
  end
@@ -1,24 +1,38 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
2
 
3
3
  require 'rexml/xpath'
4
- require 'test/unit'
4
+ require 'spec'
5
5
  require 'buildmaster'
6
6
  require 'buildmaster/source_content'
7
+ require 'buildmaster/cotta'
8
+ require 'buildmaster/cotta/in_memory_system'
7
9
 
8
10
  module BuildMaster
9
- class XTemplateTest < Test::Unit::TestCase
10
- protected
11
- def setup
12
- super
13
- end
14
-
15
- public
16
- def test_should_initialize_with_io
17
- template = BuildMaster::XTemplate.new(File.open(File.join(File.dirname(__FILE__), "template.xhtml")), Hash.new)
18
- end
11
+
12
+ context 'XTemplate' do
13
+ setup do
14
+ @cotta = Cotta.new(InMemorySystem.new)
15
+ end
16
+
17
+ specify 'should_initialize_with_io' do
18
+ template_file = @cotta.file('template.xhtml')
19
+ template_file.save <<CONTENT
20
+ <html xmlns="http://www.w3.org/1999/xhtml"
21
+ xmlns:template="http://buildmaster.rubyforge.org/xemplate/1.0">
22
+ <head>
23
+ <title>JBehave - <template:include elements="/html/head/title/text()"/></title>
24
+ <template:include elements="/html/head/*[not(name()='title')]"/>
25
+ </head>
26
+
27
+ <body>
28
+ </body>
29
+ </html>
30
+ CONTENT
31
+ template = template_file.read {|file| BuildMaster::XTemplate.new(file, Hash.new)}
32
+ end
19
33
 
20
- def test_should_initialize_with_content
21
- template_content = <<CONTENT
34
+ specify 'should_initialize_with_content' do
35
+ template_content = <<CONTENT
22
36
  <html xmlns="http://www.w3.org/1999/xhtml"
23
37
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
24
38
  <head>
@@ -27,13 +41,13 @@ module BuildMaster
27
41
  <body>Body</body>
28
42
  </html>
29
43
  CONTENT
30
- template = XTemplate.new(template_content, Hash.new)
31
- xml_output = template.process(SourceContent.new(Pathname.new('content'), ''))
32
- assert_equal('Body', REXML::XPath.first(xml_output, '/html/body').text)
33
- end
44
+ template = XTemplate.new(template_content, Hash.new)
45
+ xml_output = template.process(SourceContent.new(Pathname.new('content'), ''))
46
+ REXML::XPath.first(xml_output, '/html/body').text.should_equal 'Body'
47
+ end
34
48
 
35
- def test_should_hook_up_templatelets
36
- template_content = <<INCLUDE_CONTENT
49
+ specify 'should_hook_up_templatelets' do
50
+ template_content = <<INCLUDE_CONTENT
37
51
  <html xmlns="http://www.w3.org/1999/xhtml"
38
52
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
39
53
  <head>
@@ -48,7 +62,7 @@ CONTENT
48
62
  </body>
49
63
  </html>
50
64
  INCLUDE_CONTENT
51
- source_content = <<INCLUDE_SOURCE
65
+ source_content = <<INCLUDE_SOURCE
52
66
  <!DOCTYPE html
53
67
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
54
68
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -57,23 +71,23 @@ INCLUDE_CONTENT
57
71
  <body></body>
58
72
  </html>
59
73
  INCLUDE_SOURCE
60
- template = XTemplate.new(template_content, load_templatelets)
61
- xml_document = template.process(SourceContent.new(nil, source_content))
62
- xml_output = REXML::Document.new(xml_document.to_s())
63
- assert_equal('BuildMaster - Index', REXML::XPath.first(xml_output, '/html/head/title').text)
64
- assert_equal('one', REXML::XPath.first(xml_output, '/html/body/ul/li').text)
65
- end
66
-
67
- def what?(path)
68
- return true
69
- end
74
+ template = XTemplate.new(template_content, load_templatelets)
75
+ xml_document = template.process(SourceContent.new(nil, source_content))
76
+ xml_output = REXML::Document.new(xml_document.to_s())
77
+ REXML::XPath.first(xml_output, '/html/head/title').text.should_equal 'BuildMaster - Index'
78
+ REXML::XPath.first(xml_output, '/html/body/ul/li').text.should_equal 'one'
79
+ end
70
80
 
71
- def index_file?(path)
72
- return true
73
- end
74
-
75
- def load_templatelets
76
- return {'when' => When.new(self, self)}
77
- end
78
- end
81
+ def what?(path)
82
+ return true
83
+ end
84
+
85
+ def index_file?(path)
86
+ return true
87
+ end
88
+
89
+ def load_templatelets
90
+ return {'when' => When.new(self, self)}
91
+ end
92
+ end
79
93
  end