BuildMaster 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -2,16 +2,20 @@ $:.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 'buildmaster/site_spec'
7
7
  require 'buildmaster/source_content'
8
- require 'buildmaster/template_exception'
8
+ require 'buildmaster/template_error'
9
9
  require 'buildmaster/templatelets'
10
+ require 'buildmaster/cotta'
11
+ require 'buildmaster/cotta/in_memory_system'
10
12
 
11
13
  module BuildMaster
12
- class CommonTemplateletTest < Test::Unit::TestCase
13
- def setup
14
- @site_spec = SiteSpec.new
14
+ module HelperMethods
15
+
16
+ def setup_spec
17
+ @cotta = Cotta.new(InMemorySystem.new)
18
+ @site_spec = BuildMaster::SiteSpec.new(nil, @cotta)
15
19
  @site_spec.content_dir = '/tmp/workingdir/content'
16
20
  end
17
21
 
@@ -20,8 +24,5 @@ class CommonTemplateletTest < Test::Unit::TestCase
20
24
  element.name=name
21
25
  return element
22
26
  end
23
-
24
- def test_dummy
25
- end
26
27
  end
27
28
  end
@@ -4,32 +4,46 @@ require 'common_templatelet_test'
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
6
6
 
7
- require 'buildmaster/template_exception'
7
+ require 'buildmaster/template_error'
8
8
  require 'buildmaster/templatelets/attribute'
9
9
 
10
10
  module BuildMaster
11
- class AttributeTest < CommonTemplateletTest
12
- def test_should_set_attribute_based_on_evaluation
11
+
12
+ class AttributeForTest
13
+ def initialize(logger)
14
+ @logger = logger
15
+ end
16
+
17
+ def expression(path)
18
+ @logger.expression_called_with(path)
19
+ return 'value'
20
+ end
21
+ end
22
+
23
+ context 'AttributeTest' do
24
+ include HelperMethods
25
+
26
+ setup do
27
+ setup_spec
28
+ end
29
+
30
+ specify 'should_set_attribute_based_on_evaluation' do
13
31
  templatelet = Attribute.new(AttributeForTest.new(self))
14
32
  target = create_element('a')
15
33
  template_element = create_attribute_element('attr-name', 'expression')
16
34
  expected_pathname = Pathname.new('/path')
17
35
  @source_path = SourceContent.new(expected_pathname, nil)
18
36
  templatelet.process(target, template_element, @source_path)
19
- assert_equal('value', target.attributes['attr-name'])
20
- assert_equal(expected_pathname, @path_logged)
37
+ target.attributes['attr-name'].should_equal 'value'
38
+ @path_logged.should_equal expected_pathname
21
39
  end
22
40
 
23
- def test_should_check_for_expression_responder
41
+ specify 'should_check_for_expression_responder' do
24
42
  target = create_element('a')
25
43
  template_element = create_attribute_element('name', 'eval')
26
44
  source_path = SourceContent.new(Pathname.new('./'), create_element('name'))
27
- begin
28
- Attribute.new(self).process(target, template_element, source_path)
29
- fail('template exception should have been thrown')
30
- rescue TemplateException => e
31
- assert_equal(true, e.message.include?('eval'))
32
- end
45
+ attribute = Attribute.new(self)
46
+ lambda {attribute.process(target, template_element, source_path)}.should_raise TemplateError
33
47
  end
34
48
 
35
49
  def create_attribute_element(name, eval)
@@ -43,15 +57,4 @@ class AttributeTest < CommonTemplateletTest
43
57
  @path_logged = path
44
58
  end
45
59
  end
46
-
47
- class AttributeForTest
48
- def initialize(logger)
49
- @logger = logger
50
- end
51
-
52
- def expression(path)
53
- @logger.expression_called_with(path)
54
- return 'value'
55
- end
56
- end
57
60
  end
@@ -8,8 +8,28 @@ require 'buildmaster/template_runner'
8
8
 
9
9
  module BuildMaster
10
10
 
11
- class EachTest < CommonTemplateletTest
12
- def test_should_iteration_through_selected_elements
11
+ class MySite < SiteSpec
12
+ def load_document(path)
13
+ content = <<CONTENT
14
+ <rss>
15
+ <item>
16
+ <title>Title One</title>
17
+ <pubDate>Today</pubDate>
18
+ </item>
19
+ <item>
20
+ <title>Title Two</title>
21
+ <pubDate>Tomorrow</pubDate>
22
+ </item>
23
+ </rss>
24
+ CONTENT
25
+
26
+ return REXML::Document.new(content)
27
+ end
28
+ end
29
+
30
+ context 'EachTest' do
31
+ include HelperMethods
32
+ specify 'should_iteration_through_selected_elements' do
13
33
  template_content = <<CONTENT
14
34
  <each source="rss" select="/rss/item" count="2">
15
35
  <div class="NewsItem">
@@ -20,11 +40,11 @@ class EachTest < CommonTemplateletTest
20
40
  CONTENT
21
41
  target = create_element('test')
22
42
  template = REXML::XPath.first(REXML::Document.new(template_content), '/each')
23
- site = MySite.new
43
+ site = MySite.new(@site_spec, @cotta)
24
44
  each_processor = Each.new(site)
25
45
  each_processor.process(target, template, SourceContent.new('doc/doc.html', nil))
26
- assert_equal('NewsItem', REXML::XPath.first(target, 'div').attributes['class'])
27
- assert_equal(2, REXML::XPath.match(target, 'div').size)
46
+ REXML::XPath.first(target, 'div').attributes['class'].should_equal 'NewsItem'
47
+ REXML::XPath.match(target, 'div').size.should_equal 2
28
48
  end
29
49
 
30
50
  def on_line_test_rss_uri_need_start_a_server
@@ -41,29 +61,10 @@ CONTENT
41
61
  site = MySite.new
42
62
  each_processor = Each.new(site)
43
63
  each_processor.process(target, template, SourceContent.new('doc/doc.html', nil))
44
- assert_equal('NewsItem', REXML::XPath.first(target, 'div').attributes['class'])
45
- assert_equal(2, REXML::XPath.match(target, 'div').size)
64
+ REXML::XPath.first(target, 'div').attributes['class'].should_equal 'NewsItem'
65
+ REXML::XPath.match(target, 'div').size.should_equal 2
46
66
 
47
67
  end
48
68
  end
49
69
 
50
- class MySite < SiteSpec
51
- def load_document(path)
52
- content = <<CONTENT
53
- <rss>
54
- <item>
55
- <title>Title One</title>
56
- <pubDate>Today</pubDate>
57
- </item>
58
- <item>
59
- <title>Title Two</title>
60
- <pubDate>Tomorrow</pubDate>
61
- </item>
62
- </rss>
63
- CONTENT
64
-
65
- return REXML::Document.new(content)
66
- end
67
- end
68
-
69
70
  end
@@ -5,9 +5,10 @@ require 'common_templatelet_test'
5
5
  $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
6
6
 
7
7
  module BuildMaster
8
- class HrefTest < CommonTemplateletTest
9
- def setup
10
- super
8
+ context 'HrefTest' do
9
+ include HelperMethods
10
+ setup do
11
+ setup_spec
11
12
  @template_element = create_element('href')
12
13
  @target_element = create_element('a')
13
14
  @href = Href.new(@site_spec)
@@ -17,38 +18,38 @@ class HrefTest < CommonTemplateletTest
17
18
  SourceContent.new(Pathname.new(path), nil)
18
19
  end
19
20
 
20
- def test_should_populate_href_attribute_with_full_url
21
+ specify 'should_populate_href_attribute_with_full_url' do
21
22
  expected_url = 'http://www.rubyforge.org'
22
23
  @template_element.attributes['url']=expected_url
23
24
  @href.process(@target_element, @template_element, source('index.html'))
24
- assert_equal(expected_url, @target_element.attributes['href'])
25
+ @target_element.attributes['href'].should_equal expected_url
25
26
  end
26
27
 
27
- def test_should_populate_href_attribute_with_relative_path
28
+ specify 'should_populate_href_attribute_with_relative_path' do
28
29
  @template_element.attributes['url']='doc/doc.html'
29
30
  @href.process(@target_element, @template_element, source('download/index.html'))
30
- assert_equal('../doc/doc.html', @target_element.attributes['href'])
31
+ @target_element.attributes['href'].should_equal '../doc/doc.html'
31
32
  end
32
33
 
33
- def test_should_support_image_tag_by_generating_src_attribute
34
+ specify 'should_support_image_tag_by_generating_src_attribute' do
34
35
  @template_element.attributes['url']='doc/doc.gif'
35
36
  @target_element = create_element('img')
36
37
  @href.process(@target_element, @template_element, source('download/download.html'))
37
- assert_equal('../doc/doc.gif', @target_element.attributes['src'])
38
+ @target_element.attributes['src'].should_equal '../doc/doc.gif'
38
39
  end
39
40
 
40
- def test_should_handle_external_links
41
+ specify 'should_handle_external_links' do
41
42
  @template_element.attributes['url'] = 'http://www.google.com'
42
43
  @target_element = create_element('img')
43
44
  @href.process(@target_element, @template_element, source('download/download.html'))
44
- assert_equal('http://www.google.com', @target_element.attributes['src'])
45
+ @target_element.attributes['src'].should_equal 'http://www.google.com'
45
46
  end
46
47
 
47
- def test_should_handle_absolute_path
48
+ specify 'should_handle_absolute_path' do
48
49
  @template_element.attributes['url'] = '/doc.html'
49
50
  @target_element = create_element('img')
50
51
  @href.process(@target_element, @template_element, source('download/download.html'))
51
- assert_equal('../doc.html', @target_element.attributes['src'])
52
+ @target_element.attributes['src'].should_equal '../doc.html'
52
53
  end
53
54
 
54
55
  end
@@ -11,8 +11,15 @@ require 'buildmaster/source_content'
11
11
  require 'buildmaster/templatelets/include'
12
12
 
13
13
  module BuildMaster
14
- class IncludeTest < CommonTemplateletTest
15
- def test_should_include_the_source
14
+
15
+ context 'IncludeTest' do
16
+ include HelperMethods
17
+
18
+ setup do
19
+ setup_spec
20
+ end
21
+
22
+ specify 'should_include_the_source' do
16
23
  target = create_element('target')
17
24
  template = create_element('include')
18
25
  template.attributes['elements'] = '/item/*'
@@ -26,8 +33,8 @@ CONTENT
26
33
  source = SourceContent.new(Pathname.new('doc/index.html'), REXML::Document.new(source_content))
27
34
  include = Include.new(SiteSpec.new)
28
35
  include.process(target, template, source)
29
- assert_equal('test', REXML::XPath.first(target, 'one').text)
30
- assert_equal('text', target.text.strip!)
36
+ REXML::XPath.first(target, 'one').text.should_equal 'test'
37
+ target.text.strip!.should_equal 'text'
31
38
  end
32
39
  end
33
40
  end
@@ -10,8 +10,14 @@ require 'buildmaster/site_spec'
10
10
  require 'buildmaster/source_content'
11
11
 
12
12
  module BuildMaster
13
- class LinkTest < CommonTemplateletTest
14
- def test_should_generate_link_with_relative_path
13
+ context 'LinkTest' do
14
+ include HelperMethods
15
+
16
+ setup do
17
+ setup_spec
18
+ end
19
+
20
+ specify 'should_generate_link_with_relative_path' do
15
21
  target = create_element('div')
16
22
  template_content = <<CONTENT
17
23
  <?xml ?>
@@ -25,11 +31,11 @@ CONTENT
25
31
  link = Link.new(SiteSpec.new)
26
32
  link.process(target, template, SourceContent.new(Pathname.new('doc/doc.html'), source))
27
33
  actual = REXML::XPath.first(target, 'a')
28
- assert_equal('../content/path.html', actual.attributes['href'])
29
- assert_equal('text', actual.text)
34
+ actual.attributes['href'].should_equal '../content/path.html'
35
+ actual.text.should_equal 'text'
30
36
  end
31
37
 
32
- def test_should_copy_all_attributes
38
+ specify 'should_copy_all_attributes' do
33
39
  target = create_element('div')
34
40
  template = create_element('link')
35
41
  template.attributes['href'] = 'content/path.html'
@@ -39,11 +45,11 @@ CONTENT
39
45
  link = Link.new(SiteSpec.new)
40
46
  link.process(target, template, SourceContent.new(Pathname.new('doc/doc.html'), source))
41
47
  actual = REXML::XPath.first(target, 'a')
42
- assert_equal('value1', actual.attributes['attribute1'])
43
- assert_equal('value2', actual.attributes['attribute2'])
48
+ actual.attributes['attribute1'].should_equal 'value1'
49
+ actual.attributes['attribute2'].should_equal 'value2'
44
50
  end
45
51
 
46
- def test_should_handle_absolute_path
52
+ specify 'should_handle_absolute_path' do
47
53
  target = create_element('div')
48
54
  template = create_element('link')
49
55
  template.attributes['href'] = '/content/path.html'
@@ -51,10 +57,10 @@ CONTENT
51
57
  link = Link.new(SiteSpec.new)
52
58
  link.process(target, template, SourceContent.new(Pathname.new('doc/iste/doc.html'), source))
53
59
  actual = REXML::XPath.first(target, 'a')
54
- assert_equal('../../content/path.html', actual.attributes['href'])
60
+ actual.attributes['href'].should_equal '../../content/path.html'
55
61
  end
56
62
 
57
- def test_should_generate_div_with_current_class_attribute_if_link_is_on_current_page
63
+ specify 'should_generate_div_with_current_class_attribute_if_link_is_on_current_page' do
58
64
  target = create_element('div')
59
65
  template = create_element('link')
60
66
  template.attributes['href'] = '/content/path.html'
@@ -62,8 +68,8 @@ CONTENT
62
68
  link = Link.new(SiteSpec.new)
63
69
  link.process(target, template, SourceContent.new(Pathname.new('content/path.html'), source))
64
70
  actual = REXML::XPath.first(target, 'div')
65
- assert_equal(nil, actual.attributes['href'])
66
- assert_equal('current', actual.attributes['class'])
71
+ actual.attributes['href'].should_equal nil
72
+ actual.attributes['class'].should_equal 'current'
67
73
  end
68
74
 
69
75
  end
@@ -10,26 +10,31 @@ require 'buildmaster/site_spec'
10
10
  require 'buildmaster/source_content'
11
11
 
12
12
  module BuildMaster
13
- class TextTest < CommonTemplateletTest
14
- def test_should_generate_text_based_on_property
13
+ context 'TextTest' do
14
+ include HelperMethods
15
+ setup do
16
+ setup_spec
17
+ end
18
+
19
+ specify 'should_generate_text_based_on_property' do
15
20
  target = create_element('target')
16
21
  template = create_element('text')
17
22
  template.attributes['property'] = 'property'
18
23
  text = Text.new({'property' => 'text'})
19
24
  text.process(target, template, nil)
20
- assert_equal('text', target.text)
25
+ target.text.should_equal 'text'
21
26
  end
22
27
 
23
- def test_should_throw_exception_if_property_not_set
28
+ specify 'should_throw_exception_if_property_not_set' do
24
29
  target = create_element('target')
25
30
  template = create_element('text')
26
31
  template.attributes['property'] = 'one'
27
32
  text = Text.new(Hash.new)
28
33
  begin
29
34
  text.process(target, template, nil)
30
- fail('TemplateException should have been thrown')
31
- rescue TemplateException => exception
32
- assert_equal(true, exception.message.include?('one'))
35
+ fail('TemplateError should have been thrown')
36
+ rescue TemplateError => exception
37
+ exception.message.include?('one').should_equal true
33
38
  end
34
39
  end
35
40
  end
@@ -10,8 +10,14 @@ require 'buildmaster/site_spec'
10
10
  require 'buildmaster/templatelets'
11
11
 
12
12
  module BuildMaster
13
- class WhenTest < CommonTemplateletTest
14
- def test_should_process_child_when_evaluated_true
13
+ context 'WhenTest' do
14
+ include HelperMethods
15
+
16
+ setup do
17
+ setup_spec
18
+ end
19
+
20
+ specify 'should_process_child_when_evaluated_true' do
15
21
  target = create_element('target')
16
22
  template_content = <<CONTENT
17
23
  <when test='expression_for_true'>
@@ -23,10 +29,10 @@ CONTENT
23
29
  when_processor = When.new(self, self)
24
30
  when_processor.process(target, template, self)
25
31
  actual = REXML::XPath.first(target, 'h1')
26
- assert_equal('Header', actual.text)
32
+ actual.text.should_equal 'Header'
27
33
  end
28
34
 
29
- def test_should_not_process_child_when_evaluated_false
35
+ specify 'should_not_process_child_when_evaluated_false' do
30
36
  target = create_element('target')
31
37
  template_content = <<CONTENT
32
38
  <when test='expression_for_false'>
@@ -37,7 +43,7 @@ CONTENT
37
43
  template = REXML::XPath.first(template_document, '/when')
38
44
  when_processor = When.new(self, self)
39
45
  when_processor.process(target, template, self)
40
- assert_equal(0, target.size)
46
+ target.size.should_equal 0
41
47
  end
42
48
 
43
49
  def path
@@ -0,0 +1,29 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
2
+
3
+ require 'spec'
4
+ require 'windows/iis_driver'
5
+
6
+ module BuildMaster
7
+
8
+ context 'IIS Driver' do
9
+
10
+ setup do
11
+ @system = InMemorySystem.new
12
+ @driver = IisDriver.new(Cotta.new(@system))
13
+ end
14
+
15
+ specify 'should work on real system - requires IIS installed and not running' do
16
+ @driver = IisDriver.new
17
+ @driver.start
18
+ @driver.status
19
+ @driver.stop
20
+ end
21
+
22
+ specify 'should initiate start command' do
23
+ @driver.start
24
+ #@system.executed_commands[0].should_equal 'C:\WINDOWS\system32\iisreset.exe /start'
25
+ @system.executed_commands[0].should_equal 'sc start W3SVC'
26
+ end
27
+
28
+ end
29
+ end