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,31 +1,36 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
2
 
3
- require 'test/unit'
3
+ require 'spec'
4
4
 
5
5
  require 'buildmaster/build_number_file'
6
+ require 'buildmaster/cotta'
7
+ require 'buildmaster/cotta/in_memory_system'
6
8
 
7
9
  module BuildMaster
8
- class BuildNumberFileTest < Test::Unit::TestCase
9
- def test_load_file
10
- path = tmp_file(2)
10
+ context 'BuildNumberFileTest' do
11
+ setup do
12
+ @cotta = Cotta.new(InMemorySystem.new)
13
+ end
14
+
15
+ teardown do
16
+ @cotta = nil
17
+ end
18
+
19
+ specify 'load_file' do
20
+ path = @cotta.file('tmp/buildnumber')
21
+ path.save(2)
11
22
  build_number = BuildNumberFile.new(path)
12
- assert_equal(2, build_number.number)
23
+ build_number.number.should_equal 2
13
24
  end
14
25
 
15
- def test_increase_build
16
- path = tmp_file(3)
26
+ specify 'increase_build' do
27
+ path = @cotta.file('tmp/buildnumber')
28
+ path.save(3)
17
29
  build_number = BuildNumberFile.new(path)
18
30
  build_number.increase_build
19
- assert_equal(4, build_number.number)
31
+ build_number.number.should_equal 4
20
32
  reloaded = BuildNumberFile.new(path)
21
- assert_equal(4, reloaded.number)
22
- end
23
-
24
- private
25
- def tmp_file(build_number)
26
- path = File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'buildnumber')
27
- File.open(path, "w") {|file| file.puts build_number}
28
- return path
33
+ reloaded.number.should_equal 4
29
34
  end
30
35
  end
31
36
  end
@@ -1,64 +1,62 @@
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
9
 
8
- class CvsDriverTest < Test::Unit::TestCase
9
- protected
10
- def setUp()
11
- super
10
+ context 'CvsDriverTest' do
11
+
12
+ setup do
13
+ @system = InMemorySystem.new
14
+ @cotta = Cotta.new(@system)
15
+ @working = @cotta.dir('working')
12
16
  end
13
17
 
14
- private
15
- def ensure_folder_exists(path)
16
- if (not File.exists? path)
17
- Dir.mkdir(path)
18
- end
18
+ teardown do
19
+ @system = nil
20
+ @cotta = nil
21
+ @working = nil
19
22
  end
20
-
21
- public
22
- def test_load_CvsInfo
23
- folder = 'tmp'
24
- ensure_folder_exists(folder);
23
+
24
+ specify 'load_CvsInfo' do
25
+ folder = @cotta.dir('tmp')
26
+ folder.mkdirs
25
27
  root = ':ext:wolfdancer@cvsserver.com:/cvs/root'
26
28
  repository = 'xpe'
27
- write("#{folder}/ROOT", root)
28
- write("#{folder}/Repository", repository)
29
+ folder.file('ROOT').save(root)
30
+ folder.file('Repository').save(repository)
29
31
  cvs = CvsInfo.load(folder)
30
- assert_equal(root, cvs.root)
31
- assert_equal(repository, cvs.repository)
32
+ cvs.root.should_equal root
33
+ cvs.repository.should_equal repository
32
34
  end
33
35
 
34
- def tes_checkout
35
- log = ''
36
- client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
36
+ specify 'checkout' do
37
+ client = CvsDriver.new(CvsInfo.new('root', 'module'), @working)
37
38
  client.checkout
38
- assert_equal('cvs -d root co -d working module', log)
39
+ @system.executed_commands.size.should_equal 1
40
+ @system.executed_commands[0].should_equal 'cvs -d root co -d working module'
39
41
  end
40
42
 
41
- def test_update
43
+ specify 'update' do
42
44
  log = ''
43
- client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
45
+ client = CvsDriver.new(CvsInfo.new('root', 'module'), @working)
44
46
  client.update
45
- assert_equal('cvs -d root update working', log)
47
+ @system.executed_commands.size.should_equal 1
48
+ @system.executed_commands[0].should_equal 'cvs -d root update working'
46
49
  client.update('-PAd')
47
- assert_equal('cvs -d root update -PAd working', log)
50
+ @system.executed_commands.size.should_equal 2
51
+ @system.executed_commands[1].should_equal 'cvs -d root update -PAd working'
48
52
  end
49
53
 
50
- def test_command
54
+ specify 'command' do
51
55
  log = ''
52
- client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
56
+ client = CvsDriver.new(CvsInfo.new('root', 'module'), @working)
53
57
  client.command('command -option argument')
54
- assert_equal('cvs -d root command -option argument working', log)
55
- end
56
-
57
- private
58
- def write(fileName, content)
59
- File.open(fileName, "w") do |file|
60
- file.puts content
61
- end
58
+ @system.executed_commands.size.should_equal 1
59
+ @system.executed_commands[0].should_equal 'cvs -d root command -option argument working'
62
60
  end
63
61
 
64
62
  end
@@ -1,76 +1,100 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
2
 
3
- require 'test/unit'
3
+ require 'spec'
4
4
  require 'rexml/document'
5
5
  require 'pathname'
6
6
  require 'buildmaster/file_processor'
7
7
  require 'buildmaster/xtemplate'
8
+ require 'buildmaster/cotta'
9
+ require 'buildmaster/cotta/in_memory_system'
10
+
8
11
 
9
12
  module BuildMaster
10
- class FileProcessorTest < Test::Unit::TestCase
11
- def test_should_know_content_and_target
13
+
14
+ context 'File Processor' do
15
+ setup do
16
+ @cotta = Cotta.new(InMemorySystem.new)
17
+ @cotta.file('content').save(<<CONTENT
18
+ line one
19
+ line two
20
+ line three
21
+ CONTENT
22
+ )
23
+ end
24
+
25
+ teardown do
26
+ @cotta = nil
27
+ end
28
+
29
+ specify 'should know content and target' do
12
30
  template = XTemplate.new(<<CONTENT
13
31
  <html xmlns="http://www.w3.org/1999/xhtml"
14
32
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
15
33
  </html>
16
34
  CONTENT
17
35
  )
18
- site_spec = SiteSpec.new
19
- current_dir = File.dirname(__FILE__)
20
- site_spec.content_dir = File.join(current_dir, "content")
21
- site_spec.output_dir = File.join(current_dir, "output")
22
- processor = FileProcessor.new(template, File.join(current_dir, 'content', 'index.html'), site_spec)
23
- assert_equal(File.join(current_dir, 'content', 'index.html'), processor.path_to_content_file)
24
- assert_equal(true, processor.is_html?)
36
+ site_spec = SiteSpec.new('file.txt', @cotta)
37
+ site_spec.content_dir = 'content'
38
+ site_spec.output_dir = 'output'
39
+ processor = FileProcessor.new(template, @cotta.file('content/index.html'), site_spec)
40
+ processor.content_file.path.should_equal(Pathname.new('content/index.html'))
41
+ processor.is_html?.should_equal(true)
25
42
  end
26
43
 
27
- def test_should_know_html_target
44
+ specify 'should know HTML target file' do
28
45
  template = XTemplate.new(<<CONTENT
29
46
  <html xmlns="http://www.w3.org/1999/xhtml"
30
47
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
31
48
  </html>
32
49
  CONTENT
33
50
  )
34
- site_spec = SiteSpec.new
35
- current_dir = File.dirname(__FILE__)
36
- site_spec.content_dir = File.join(current_dir, "content")
37
- site_spec.output_dir = File.join(current_dir, "output")
38
- processor = FileProcessor.new(template, File.join(current_dir, 'content', 'index.gif'), site_spec)
39
- assert_equal(File.join(current_dir, 'content', 'index.gif'), processor.path_to_content_file)
40
- assert_equal(false, processor.is_html?)
41
- assert_equal(nil, processor.generate_document)
51
+ site_spec = SiteSpec.new(nil, @cotta)
52
+ current_dir = @cotta.dir('root')
53
+ site_spec.content_dir = 'root/content'
54
+ site_spec.output_dir = 'root/output'
55
+ processor = FileProcessor.new(template, current_dir.dir('content').file('index.gif'), site_spec)
56
+ processor.content_file.path.should_equal current_dir.dir('content').file('index.gif').path
57
+ processor.is_html?.should_equal false
58
+ processor.generate_document.should_equal nil
42
59
  end
43
60
 
44
- def test_should_load_from_target
61
+ specify 'should load from target file' do
45
62
  template_content = <<CONTENT
46
63
  <html xmlns="http://www.w3.org/1999/xhtml"
47
64
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
48
65
  </html>
49
66
  CONTENT
50
- site_spec = SiteSpec.new
51
- current_dir = File.dirname(__FILE__)
67
+ site_spec = SiteSpec.new(__FILE__, @cotta)
68
+ current_dir = @cotta.dir(File.dirname(__FILE__))
69
+ current_dir.dir('site').dir('content').file('index.html').save
70
+ current_dir.dir('site').dir('content').file('index.gif').save
71
+ current_dir.dir('site').dir('content').file('textile.textile').save
72
+ current_dir.dir('site').dir('content').file('markdown.markdown').save
52
73
  site_spec.template = template_content
53
- site_spec.content_dir = File.join(current_dir, 'site', 'content')
54
- site_spec.output_dir = File.join(current_dir, "output")
74
+ site_spec.content_dir = 'site/content'
75
+ site_spec.output_dir = 'output'
55
76
  processor = FileProcessor.for_request_path('/index.html', site_spec)
56
- assert_equal(File.join(site_spec.content_dir, 'index.html'), processor.path_to_content_file)
77
+ processor.content_file.should_equal site_spec.content_dir.file('index.html')
78
+
57
79
  processor = FileProcessor.for_request_path('/index.gif', site_spec)
58
- assert_equal(File.join(site_spec.content_dir, 'index.gif'), processor.path_to_content_file)
80
+ processor.content_file.should_equal site_spec.content_dir.file('index.gif')
81
+
59
82
  processor = FileProcessor.for_request_path('/textile.html', site_spec)
60
- assert_equal(File.join(site_spec.content_dir, 'textile.textile'), processor.path_to_content_file)
83
+ processor.content_file.should_equal site_spec.content_dir.file('textile.textile')
84
+
61
85
  processor = FileProcessor.for_request_path('/markdown.html', site_spec)
62
- assert_equal(File.join(site_spec.content_dir, 'markdown.markdown'), processor.path_to_content_file)
86
+ processor.content_file.should_equal site_spec.content_dir.file('markdown.markdown')
63
87
  end
64
88
 
65
89
  def output_dir
66
- return 'tmp'
90
+ return @cotta.dir('tmp')
67
91
  end
68
92
 
69
93
  def relative_to_root(path)
70
94
  return Pathname.new('tmp')
71
95
  end
72
-
73
- def test_mark_down_support
96
+
97
+ specify 'should have support for markdown content' do
74
98
  template_content = <<CONTENT
75
99
  <html xmlns="http://www.w3.org/1999/xhtml"
76
100
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
@@ -83,7 +107,7 @@ CONTENT
83
107
  hash = {'include' => Include.new(self)}
84
108
  template = XTemplate.new(template_content, hash)
85
109
 
86
- processor = FileProcessor.new(template, "content_path", self)
110
+ processor = FileProcessor.new(template, @cotta.file('content_path'), self)
87
111
  markdown_content = <<CONTENT
88
112
  --------------------------------------------
89
113
  Title Here
@@ -93,8 +117,8 @@ Header
93
117
  CONTENT
94
118
  document = processor.process_markdown(markdown_content)
95
119
  document = REXML::Document.new(document.to_s)
96
- assert_equal('Title Here', REXML::XPath.first(document, '/html/head/title').text)
97
- assert_equal('Header', REXML::XPath.first(document, '/html/body/h1').text)
120
+ REXML::XPath.first(document, '/html/head/title').text.should_equal 'Title Here'
121
+ REXML::XPath.first(document, '/html/body/h1').text.should_equal 'Header'
98
122
  end
99
123
 
100
124
  end
@@ -1,23 +1,51 @@
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
9
 
8
- class JavaManifestTest < Test::Unit::TestCase
9
- def test_loading_manifest
10
- manifest = JavaManifest.new(File.join(File.dirname(__FILE__), "manifest.mf"))
10
+ context 'JavaManifestTest' do
11
+ setup do
12
+ @cotta = Cotta.new(InMemorySystem.new)
13
+ end
14
+
15
+ teardown do
16
+ @cotta = nil
17
+ end
18
+
19
+ specify 'loading_manifest' do
20
+ file = @cotta.file('dir/manifest.mf')
21
+ file.save(<<CONTENT
22
+ Implementation-Version: 2.3.3
23
+ Implementation-Build: 1139
24
+
25
+ Implementation-Vendor: Vendor
26
+ Implementation-Number: Number
27
+ CONTENT
28
+ )
29
+ manifest = JavaManifest.new(file)
11
30
  version = manifest.version
12
- assert_equal(version.number, "2.3.3")
31
+ "2.3.3".should_equal version.number
13
32
  end
14
33
 
15
- def test_increase_build
16
- manifest = JavaManifest.new(File.join(File.dirname(__FILE__), "manifest.mf"))
34
+ specify 'increase_build' do
35
+ file = @cotta.file('dir/manifest.mf')
36
+ file.save(<<CONTENT
37
+ Implementation-Version: 2.3.3
38
+ Implementation-Build: 1139
39
+
40
+ Implementation-Vendor: Vendor
41
+ Implementation-Number: Number
42
+ CONTENT
43
+ )
44
+ manifest = JavaManifest.new(file)
17
45
  build_number = manifest.version.build
18
46
  version = manifest.increase_build
19
- assert_equal(version.build, build_number + 1)
20
- assert_equal(version.build, manifest.version.build)
47
+ (build_number + 1).should_equal version.build
48
+ manifest.version.build.should_equal version.build
21
49
  end
22
50
  end
23
51
  end
@@ -1,26 +1,31 @@
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
9
 
8
- class SiteSpecTest < Test::Unit::TestCase
10
+ context 'Site Specification' do
11
+ setup do
12
+ @cotta = Cotta.new(InMemorySystem.new)
13
+ end
9
14
 
10
- def test_should_get_relative_path
11
- spec = SiteSpec.new()
15
+ specify 'get relative path' do
16
+ spec = SiteSpec.new(nil, @cotta)
12
17
  spec.content_dir = '/one/two/content'
13
- assert_equal('images/logo.gif', spec.relative_to_root('/one/two/content/images/logo.gif').to_s)
18
+ spec.relative_to_root(@cotta.file('/one/two/content/images/logo.gif')).to_s.should_equal('images/logo.gif')
14
19
  end
15
20
 
16
- def test_should_support_windows_path
17
- spec = SiteSpec.new()
18
- spec.content_dir = "C:\\Work\\project\\content"
19
- assert_equal('images/logo.gif', spec.relative_to_root('C:\\Work\\project\\content\\images\\logo.gif').to_s)
21
+ specify 'supports windows path' do
22
+ spec = SiteSpec.new(nil, @cotta)
23
+ spec.content_dir = 'C:\Work\project\content'
24
+ spec.relative_to_root(@cotta.file('C:\Work\project\content\images\logo.gif')).to_s.should_equal('images/logo.gif')
20
25
  end
21
26
 
22
- def test_initialize_with_block
23
- spec = SiteSpec.new(__FILE__) do |sitespec|
27
+ specify 'initialization with block' do
28
+ spec = SiteSpec.new(__FILE__, @cotta) do |sitespec|
24
29
  sitespec.content_dir = 'content'
25
30
  sitespec.output_dir = 'output'
26
31
  sitespec.page_layout = <<CONTENT
@@ -39,10 +44,10 @@ menu_groups:
39
44
  - title: second menu group
40
45
  CONTENT
41
46
  end
42
- root = File.dirname(__FILE__)
43
- assert_equal(File.join(root, 'content'), spec.content_dir)
44
- assert_equal(File.join(root, 'output'), spec.output_dir)
45
- assert_equal(true, spec.load_template_source.to_s.include?('first menu group'))
47
+ root = @cotta.dir(__FILE__).parent
48
+ spec.content_dir.should_equal(root.dir('content'))
49
+ spec.output_dir.should_equal(root.dir('output'))
50
+ spec.load_template_source.to_s.include?('first menu group').should_equal true
46
51
  end
47
52
 
48
53
  end
@@ -1,16 +1,16 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
2
 
3
- require 'test/unit'
3
+ require 'spec'
4
4
  require 'buildmaster'
5
5
  require 'webrick'
6
6
  require 'source_file_handler'
7
7
 
8
8
  module BuildMaster
9
9
 
10
- class SourceFileHandlerTest < Test::Unit::TestCase
10
+ context 'SourceFileHandler' do
11
11
  attr_reader :path_info
12
12
 
13
- def test_should_be_able_to_find_source
13
+ specify 'should_be_able_to_find_source' do
14
14
  server = WEBrick::HTTPServer.new(:Port => 2000)
15
15
  dir = File.dirname(__FILE__)
16
16
  spec = SiteSpec.new
@@ -30,7 +30,7 @@ TEMPLATE
30
30
  @path_info = '/markdown.html'
31
31
  file_handler.service(self, self)
32
32
  document = REXML::Document.new(self['body'])
33
- assert_equal('Title', REXML::XPath.first(document, '/html/head/title').text)
33
+ REXML::XPath.first(document, '/html/head/title').text.should_equal 'Title'
34
34
  end
35
35
 
36
36
  def []=(name, value)