BuildMaster 1.1.9 → 1.1.12

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 (149) hide show
  1. data/lib/buildmaster/algorithms.rb +2 -2
  2. data/lib/buildmaster/auto.rb +27 -0
  3. data/lib/buildmaster/auto/classpath.rb +86 -0
  4. data/lib/buildmaster/auto/git.rb +38 -0
  5. data/lib/buildmaster/auto/java.rb +23 -0
  6. data/lib/buildmaster/auto/java_project.rb +185 -0
  7. data/lib/buildmaster/auto/javac_ant.rb +64 -0
  8. data/lib/buildmaster/auto/junit_ant.rb +226 -0
  9. data/lib/buildmaster/auto/mysql_server.rb +30 -0
  10. data/lib/buildmaster/auto/package_ant.rb +60 -0
  11. data/lib/buildmaster/auto/ruby_platform.rb +51 -0
  12. data/lib/buildmaster/common.rb +3 -3
  13. data/lib/buildmaster/cotta.rb +8 -3
  14. data/lib/buildmaster/cotta/command_runner.rb +19 -3
  15. data/lib/buildmaster/cotta/cotta.rb +42 -12
  16. data/lib/buildmaster/cotta/cotta_dir.rb +18 -14
  17. data/lib/buildmaster/cotta/cotta_file.rb +5 -8
  18. data/lib/buildmaster/cotta/in_memory_system.rb +15 -4
  19. data/lib/buildmaster/cotta/physical_system.rb +13 -7
  20. data/lib/buildmaster/project.rb +3 -9
  21. data/lib/buildmaster/project/ant_driver.rb +11 -7
  22. data/lib/buildmaster/project/ci.rb +2 -2
  23. data/lib/buildmaster/project/pscp_driver.rb +0 -4
  24. data/lib/buildmaster/project/ruby_forge_project.rb +0 -3
  25. data/lib/buildmaster/project/svn_admin_driver.rb +0 -4
  26. data/lib/buildmaster/project/svn_driver.rb +0 -6
  27. data/lib/buildmaster/project/svn_helper.rb +0 -6
  28. data/lib/buildmaster/project/svn_server_driver.rb +0 -5
  29. data/lib/buildmaster/project/windows/iis_driver.rb +0 -4
  30. data/lib/buildmaster/project/windows/sql_server_driver.rb +0 -1
  31. data/lib/buildmaster/site.rb +16 -4
  32. data/lib/buildmaster/site/about_handler.rb +0 -4
  33. data/lib/buildmaster/site/content_engine_repository.rb +0 -2
  34. data/lib/buildmaster/site/element_processor_by_name.rb +0 -4
  35. data/lib/buildmaster/site/file_processor.rb +0 -4
  36. data/lib/buildmaster/site/site.rb +0 -4
  37. data/lib/buildmaster/site/site_server.rb +1 -4
  38. data/lib/buildmaster/site/site_spec.rb +4 -15
  39. data/lib/buildmaster/site/source_file_handler.rb +0 -3
  40. data/lib/buildmaster/site/template_error.rb +0 -2
  41. data/lib/buildmaster/site/template_runner.rb +0 -4
  42. data/lib/buildmaster/site/templatelets.rb +9 -10
  43. data/lib/buildmaster/site/templatelets/href.rb +0 -5
  44. data/lib/buildmaster/site/templatelets/when.rb +0 -4
  45. data/lib/buildmaster/site/xtemplate.rb +0 -3
  46. data/lib/buildmaster/version +1 -1
  47. data/lib/buildmaster/win32/auto_it.rb +4 -0
  48. data/lib/buildmaster/win32/auto_it_driver.rb +45 -0
  49. data/lib/buildmaster/win32/auto_it_window.rb +82 -0
  50. data/lib/buildmaster/win32/autoit/AutoItX3.dll +0 -0
  51. data/lib/buildmaster/win32/autoit/README +1 -0
  52. data/lib/buildmaster/windows.rb +3 -3
  53. data/test/buildmaster/algorithms/tc_opn_compare.rb +2 -2
  54. data/test/buildmaster/auto/javac/src/org/rubyforge/buildmaster/javac/One.java +5 -0
  55. data/test/buildmaster/auto/javac/src/resource.txt +1 -0
  56. data/test/buildmaster/auto/javac/src2/org/rubyforge/buildmaster/javac/Two.java +9 -0
  57. data/test/buildmaster/auto/tc_classpath.rb +79 -0
  58. data/test/buildmaster/auto/tc_git.rb +32 -0
  59. data/test/buildmaster/auto/tc_java.rb +12 -0
  60. data/test/buildmaster/auto/tc_java_project.rb +78 -0
  61. data/test/buildmaster/auto/tc_java_project_slow.rb +89 -0
  62. data/test/buildmaster/auto/tc_javac_ant.rb +38 -0
  63. data/test/buildmaster/auto/tc_junit_ant.rb +187 -0
  64. data/test/buildmaster/auto/tc_package_ant.rb +29 -0
  65. data/test/buildmaster/auto/tc_ruby_platform.rb +10 -0
  66. data/test/buildmaster/common/tc_properties.rb +1 -3
  67. data/test/buildmaster/common/tc_tree_to_object.rb +1 -3
  68. data/test/buildmaster/cotta/cotta_dir_behaviors.rb +46 -8
  69. data/test/buildmaster/cotta/cotta_file_behaviors.rb +6 -6
  70. data/test/buildmaster/cotta/cotta_specifications.rb +1 -6
  71. data/test/buildmaster/cotta/file_system_behaviors.rb +1 -3
  72. data/test/buildmaster/cotta/physical_system_stub.rb +22 -3
  73. data/test/buildmaster/cotta/system_file_specifications.rb +1 -3
  74. data/test/buildmaster/cotta/tc_command_interface.rb +1 -3
  75. data/test/buildmaster/cotta/tc_command_runner.rb +1 -4
  76. data/test/buildmaster/cotta/tc_cotta.rb +5 -8
  77. data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +6 -9
  78. data/test/buildmaster/cotta/tc_cotta_dir_physical.rb +3 -6
  79. data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +3 -7
  80. data/test/buildmaster/cotta/tc_cotta_file_physical.rb +4 -4
  81. data/test/buildmaster/cotta/tc_cotta_zip_support.rb +1 -5
  82. data/test/buildmaster/cotta/tc_in_memory_system.rb +3 -7
  83. data/test/buildmaster/cotta/tc_io_chain.rb +3 -8
  84. data/test/buildmaster/cotta/tc_pathname.rb +1 -3
  85. data/test/buildmaster/cotta/tc_physical_system.rb +7 -8
  86. data/test/buildmaster/project/tc_ant_driver.rb +1 -4
  87. data/test/buildmaster/project/tc_build_number_file.rb +1 -6
  88. data/test/buildmaster/project/tc_cvs_driver.rb +1 -5
  89. data/test/buildmaster/project/tc_java_manifest.rb +1 -5
  90. data/test/buildmaster/project/tc_release.rb +1 -3
  91. data/test/buildmaster/project/tc_server_manager.rb +1 -4
  92. data/test/buildmaster/project/tc_svn_driver.rb +1 -5
  93. data/test/buildmaster/project/tc_svn_status_info.rb +1 -3
  94. data/test/buildmaster/project/tc_version_number_file.rb +1 -6
  95. data/test/buildmaster/project/windows/tc_iis_driver.rb +2 -3
  96. data/test/buildmaster/project/windows/tc_sql_server_driver.rb +2 -5
  97. data/test/buildmaster/site/content/tc_content_engine_repository.rb +1 -5
  98. data/test/buildmaster/site/tc_element_processor_by_name.rb +1 -4
  99. data/test/buildmaster/site/tc_file_processor.rb +1 -7
  100. data/test/buildmaster/site/tc_site.rb +1 -6
  101. data/test/buildmaster/site/tc_site_server.rb +2 -8
  102. data/test/buildmaster/site/tc_site_spec.rb +8 -5
  103. data/test/buildmaster/site/tc_source_file_handler.rb +1 -4
  104. data/test/buildmaster/site/tc_template_builder.rb +1 -4
  105. data/test/buildmaster/site/tc_template_error.rb +1 -3
  106. data/test/buildmaster/site/tc_template_runner.rb +2 -7
  107. data/test/buildmaster/site/tc_templatelets.rb +2 -6
  108. data/test/buildmaster/site/tc_xtemplate.rb +1 -5
  109. data/test/buildmaster/site/templatelets/common_templatelet_test.rb +1 -8
  110. data/test/buildmaster/site/templatelets/tc_attribute.rb +3 -3
  111. data/test/buildmaster/site/templatelets/tc_code.rb +2 -2
  112. data/test/buildmaster/site/templatelets/tc_each.rb +3 -3
  113. data/test/buildmaster/site/templatelets/tc_href.rb +3 -3
  114. data/test/buildmaster/site/templatelets/tc_include.rb +3 -3
  115. data/test/buildmaster/site/templatelets/tc_link.rb +3 -3
  116. data/test/buildmaster/site/templatelets/tc_text.rb +3 -3
  117. data/test/buildmaster/site/templatelets/tc_when.rb +4 -4
  118. data/test/buildmaster/site/test.rb +1 -0
  119. data/test/buildmaster/test.rb +21 -0
  120. data/test/buildmaster/win32/tc_auto_it.rb +18 -0
  121. data/test/buildmaster/win32/tc_auto_it_window.rb +17 -0
  122. data/test/manual/bms.rb +2 -4
  123. data/test/tmp/svn_test/repository/conf/authz +14 -3
  124. data/test/tmp/svn_test/repository/conf/svnserve.conf +21 -4
  125. data/test/tmp/svn_test/repository/db/current +1 -1
  126. data/test/tmp/svn_test/repository/db/format +2 -1
  127. data/test/tmp/svn_test/repository/db/revprops/0/0 +5 -0
  128. data/test/tmp/svn_test/repository/db/revprops/{1 → 0/1} +1 -1
  129. data/test/tmp/svn_test/repository/db/revprops/{2 → 0/2} +1 -1
  130. data/test/tmp/svn_test/repository/db/revprops/{3 → 0/3} +1 -1
  131. data/test/tmp/svn_test/repository/db/revprops/{4 → 0/4} +1 -1
  132. data/test/tmp/svn_test/repository/db/revs/{0 → 0/0} +0 -0
  133. data/test/tmp/svn_test/repository/db/revs/0/1 +25 -0
  134. data/test/tmp/svn_test/repository/db/revs/{2 → 0/2} +9 -9
  135. data/test/tmp/svn_test/repository/db/revs/0/3 +33 -0
  136. data/test/tmp/svn_test/repository/db/revs/{4 → 0/4} +0 -0
  137. data/test/tmp/svn_test/repository/db/txn-current +1 -0
  138. data/{lib/buildmaster/project/java/class_path.rb → test/tmp/svn_test/repository/db/txn-current-lock} +0 -0
  139. data/test/tmp/svn_test/repository/db/uuid +1 -1
  140. data/test/tmp/svn_test/repository/hooks/post-revprop-change.tmpl +1 -1
  141. data/test/tmp/svn_test/repository/hooks/pre-unlock.tmpl +1 -0
  142. data/test/tmp/svn_test/repository/hooks/start-commit.tmpl +13 -2
  143. data/test/ts_buildmaster.rb +2 -2
  144. metadata +100 -46
  145. data/lib/buildmaster/project/java.rb +0 -4
  146. data/lib/buildmaster/project/java/javac.rb +0 -9
  147. data/test/tmp/svn_test/repository/db/revprops/0 +0 -5
  148. data/test/tmp/svn_test/repository/db/revs/1 +0 -25
  149. data/test/tmp/svn_test/repository/db/revs/3 +0 -33
@@ -0,0 +1 @@
1
+ All the files in this foler are from the "AutoIt" project (http://www.autoitscript.com/autoit3/), under autoit3 license
@@ -1,3 +1,3 @@
1
- $:.unshift File.dirname(__FILE__)
2
- require 'windows/iis_driver'
3
- require 'windows/sql_server_driver'
1
+ dir = File.dirname(__FILE__)
2
+ require dir + '/project/windows/iis_driver'
3
+ require dir + '/project/windows/sql_server_driver'
@@ -1,8 +1,8 @@
1
1
  require 'spec'
2
2
 
3
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
3
+ dir = File.dirname(__FILE__)
4
4
 
5
- require 'algorithms/opn_compare'
5
+ require dir + '/../../../lib/buildmaster/algorithms/opn_compare'
6
6
 
7
7
  module BuildMaster
8
8
  module Algorithms
@@ -0,0 +1,5 @@
1
+ package org.rubyforge.buildmaster.javac;
2
+
3
+ public class One {
4
+
5
+ }
@@ -0,0 +1 @@
1
+ dummy resource file
@@ -0,0 +1,9 @@
1
+ package org.rubyforge.buildmaster.javac;
2
+
3
+ public class Two {
4
+ private One one;
5
+
6
+ public Two(One one) {
7
+ this.one = one;
8
+ }
9
+ }
@@ -0,0 +1,79 @@
1
+ require 'spec'
2
+ require File.dirname(__FILE__) + '/../../../lib/buildmaster/auto'
3
+
4
+ module BuildMaster
5
+ describe Classpath do
6
+ it 'sholud be empty when created' do
7
+ path = Classpath.new
8
+ path.should be_empty
9
+ path.include?('test').should == false
10
+ path.to_ant('id').should == ''
11
+ end
12
+
13
+ it 'should collect entries by converting to ClasspathEntry' do
14
+ path = Classpath.new
15
+ path.add(Cotta.file('entry'))
16
+ path.should_not be_empty
17
+ path.include?(Cotta.file('entry')).should == true
18
+ end
19
+
20
+ it 'should collect classpath entries directly' do
21
+ path = Classpath.new
22
+ path.add(ClasspathEntry.new(Cotta.file('entry')))
23
+ path.include?(Cotta.file('entry')).should == true
24
+ end
25
+
26
+ it 'should generate path content only when id is nil' do
27
+ path = Classpath.new
28
+ entry = Cotta.dir('entry')
29
+ path.add(entry)
30
+ path.to_ant.should == <<RESULT
31
+ <pathelement location="#{entry}"/>
32
+ RESULT
33
+ end
34
+
35
+ it 'should generate path definition part of ANT build file' do
36
+ path = Classpath.new
37
+ entry_dir = Cotta.file('entry')
38
+ path.add(entry_dir)
39
+ path.to_ant('id').should == <<RESULT
40
+ <path id="id">
41
+ <pathelement location="#{entry_dir}"/>
42
+ </path>
43
+ RESULT
44
+ end
45
+
46
+ it 'should support adding all jars in the directory' do
47
+ path = Classpath.new
48
+ jars_dir = Cotta.file('jars')
49
+ path.add_all(jars_dir)
50
+ path.to_ant('id').should == <<RESULT
51
+ <path id="id">
52
+ <fileset dir="#{jars_dir}">
53
+ <include name="**/*.jar"/>
54
+ </fileset>
55
+ </path>
56
+ RESULT
57
+ end
58
+
59
+ it 'should support adding another classpath' do
60
+ path = Classpath.new
61
+ entry = Cotta.file('entry')
62
+ path.add(entry)
63
+ path2 = Classpath.new
64
+ entry2 = Cotta.file('entry2')
65
+ path2.add(entry2)
66
+ path2.add(path)
67
+ path2.to_ant('id').should == <<RESULT
68
+ <path id="id">
69
+ <pathelement location="#{entry2}"/>
70
+ <pathelement location="#{entry}"/>
71
+ </path>
72
+ RESULT
73
+ end
74
+
75
+ it 'should allow string for path when root is set' do
76
+
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + '/../test'
2
+
3
+ module BuildMaster
4
+ describe Git do
5
+ it 'should take a directory as the working directory' do
6
+ current_dir = Cotta.parent_dir(__FILE__)
7
+ git = Git.new(current_dir)
8
+ git.work_dir.should == current_dir
9
  end
10
+
11
+ it 'should change directory and run command' do
12
+ current_dir = Cotta.parent_dir(__FILE__)
13
+ Dir.chdir('/') do
14
+ git = Git.new(current_dir)
15
+ git.status.should_not be_empty
1
16
  end
17
+ end
18
+
19
+ it 'should issue proper commands' do
20
+ system = InMemorySystem.new
21
+ cotta = Cotta.new(system)
22
+ work = cotta.dir('/tmp/work')
23
+ system.output_for_command('git pull', 'pull output')
24
+ system.output_for_command('git add .', 'add output')
25
+ system.output_for_command("git add #{work.file('file.txt')}", 'add output')
26
+ system.output_for_command("git commit -m \"comment\"", 'commit output')
27
+ system.output_for_command("git tag tag", 'tag output')
28
+ git = Git.new(work)
29
+ git.pull
30
+ git.add
31
+ git.add(work.file('file.txt'))
32
+ git.commit('comment')
33
+ git.tag('tag')
2
34
  end
3
35
  end
36
+ end
@@ -0,0 +1,12 @@
1
+ root = File.join(File.dirname(__FILE__), '..', '..', '..')
2
+ require root + '/lib/buildmaster/auto'
3
+ require 'spec'
4
+
5
+ module BuildMaster
6
+ describe Java do
7
+ it 'should get version' do
8
+ java = Java.new
9
+ java.version.should_not be_nil
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,78 @@
1
+ dir = File.dirname(__FILE__)
2
+ require dir + '/../test'
3
+ require 'spec'
4
+
5
+ module BuildMaster
6
+ describe JavaProject do
7
+ include TempDirs
8
+ it 'should take path as well as directory' do
9
+ current = current(__FILE__)
10
+ project = JavaProject.new(current) do |p|
11
+ p.output = 'output'
12
+ p.src = 'src'
13
+ p.test.src = 'test'
14
+ end
15
+ project.output.should == current.dir('output')
16
+ project.src.should == current.dir('src')
17
+ project.test.src.should == current.dir('test')
18
+ end
19
+
20
+ it 'should allow setting of the classpath' do
21
+ current = current(__FILE__)
22
+ project = JavaProject.new(current) do |p|
23
+ p.uses('lib/one.jar', 'lib/two.jar')
24
+ end
25
+ project.classpath.include?(current.file('lib/one.jar')).should == true
26
+ project.classpath.include?(current.file('lib/two.jar')).should == true
27
+ end
28
+
29
+ it 'should allow setting of the test classpath' do
30
+ current = Cotta.parent_dir(__FILE__)
31
+ project = JavaProject.new(current) do |p|
32
+ p.tests_with('lib/one', 'lib/two')
33
+ end
34
+ project.test.classpath.include?(current.dir('lib/one')).should == true
35
+ project.test.classpath.include?(current.dir('lib/two')).should == true
36
+ end
37
+
38
+ it 'should let user specify directory to add all jars in' do
39
+ current = Cotta.parent_dir(__FILE__)
40
+ project = JavaProject.new(current) do |p|
41
+ p.uses_files_in('lib/one', 'lib/two')
42
+ end
43
+ project.classpath.include?(ClasspathEntries.new(current.dir('lib/one')))
44
+ end
45
+
46
+ it 'should let user specify directory to add all test related jars' do
47
+ current = Cotta.parent_dir(__FILE__)
48
+ project = JavaProject.new(current) do |p|
49
+ p.tests_with_files_in('lib/two', 'lib/three')
50
+ end
51
+ project.test.classpath.include?(ClasspathEntries.new(current.dir('lib/two')))
52
+ project.test.classpath.include?(ClasspathEntries.new(current.dir('lib/three')))
53
+ end
54
+
55
+ it 'should construct junit task' do
56
+ current = Cotta.parent_dir(__FILE__)
57
+ project = JavaProject.new(current) do |p|
58
+ p.src = 'src'
59
+ p.output = 'output'
60
+ p.test.src = 'test'
61
+ p.uses('one', 'two')
62
+ p.tests_with('three')
63
+ end
64
+ junit = project.junit(current.dir('report')).for_test('TestClassName')
65
+ junit.test.name.should == 'TestClassName'
66
+ junit.project.should === project
67
+ junit.classpath.to_ant.should == <<RESULT
68
+ <pathelement location="#{project.test.output}"/>
69
+ <pathelement location="#{project.prod.output}"/>
70
+ <pathelement location="#{current.dir('three')}"/>
71
+ <pathelement location="#{current.dir('one')}"/>
72
+ <pathelement location="#{current.dir('two')}"/>
73
+ RESULT
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,89 @@
1
+ dir = File.dirname(__FILE__)
2
+ require dir + '/../test'
3
+ require 'spec'
4
+
5
+ module BuildMaster
6
+ describe JavaProject do
7
+ include TempDirs
8
+ it 'should be able to make' do
9
+ tmp = setup_tmp
10
+ tmp1 = tmp.dir('p1')
11
+ project = JavaProject.new(tmp) do |p|
12
+ p.src = current(__FILE__).dir('javac/src')
13
+ p.output = tmp1
14
+ end
15
+ project.make
16
+ tmp1.dir('prod').should be_exist
17
+ tmp1.file('prod/org/rubyforge/buildmaster/javac/One.class').should be_exist
18
+
19
+ tmp2 = tmp.dir('p2')
20
+ project2 = JavaProject.new(tmp) do |p|
21
+ p.src = current(__FILE__).dir('javac/src2')
22
+ p.add_project project
23
+ p.output = tmp2
24
+ end
25
+ project2.make
26
+ tmp2.dir('prod').should be_exist
27
+ tmp2.file('prod/org/rubyforge/buildmaster/javac/Two.class').should be_exist
28
+ end
29
+
30
+ it 'should compile test as well' do
31
+ tmp = setup_tmp
32
+ project = JavaProject.new(tmp) do |p|
33
+ p.src = current(__FILE__).dir('javac/src')
34
+ p.output = tmp
35
+ p.test.src = current(__FILE__).dir('javac/src2')
36
+ end
37
+ project.make()
38
+ tmp.dir('prod').should be_exist
39
+ tmp.file('prod/org/rubyforge/buildmaster/javac/One.class').should be_exist
40
+ tmp.dir('test').should be_exist
41
+ tmp.file('test/org/rubyforge/buildmaster/javac/Two.class').should be_exist
42
+ end
43
+
44
+ it 'should be able to generate classpath element for ANT build file' do
45
+ current = current(__FILE__)
46
+ output = current.dir('output')
47
+ jar = current.file('lib/lib.jar')
48
+ project = JavaProject.new(current) do |p|
49
+ p.output = output
50
+ p.classpath.add jar
51
+ end
52
+ project.to_ant.should == <<RESULT
53
+ <pathelement location="#{project.prod.output}"/>
54
+ <pathelement location="#{jar}"/>
55
+ RESULT
56
+ end
57
+
58
+ it 'should copy resources' do
59
+ current = current(__FILE__)
60
+ output = setup_tmp.dir('output')
61
+ project = JavaProject.new(current) do |p|
62
+ p.output = output
63
+ p.src = current.dir('javac/src')
64
+ p.resource = current.dir('javac/src')
65
+ end
66
+ project.make
67
+ output.file('prod/org/rubyforge/buildmaster/javac/One.java').should be_exist
68
+ end
69
+
70
+ it 'should package project with classes and source' do
71
+ current = current(__FILE__)
72
+ tmp = setup_tmp
73
+ dist = tmp.dir('dist')
74
+ output = tmp.dir('output')
75
+ project = JavaProject.new(current) do |p|
76
+ p.output = output
77
+ p.src = current.dir('javac/src')
78
+ end
79
+ project.prod.output.mkdirs
80
+ project.test.output.mkdirs
81
+ project.prod.src.mkdirs
82
+ project.package(dist, 'package')
83
+ puts dist.file('package.jar')
84
+ dist.file('package.jar').should be_exist
85
+ dist.file('package-src.zip').should be_exist
86
+ end
87
+
88
+ end
89
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../test'
2
+ require 'spec'
3
+
4
+ module BuildMaster
5
+ describe JavacAnt do
6
+ include TempDirs
7
+ it 'should compile with library' do
8
+ output = setup_tmp
9
+ output1 = output.dir('classes1')
10
+ output2 = output.dir('classes2')
11
+
12
+ # compile without any library
13
+ javac = JavacAnt.new(output1)
14
+ javac.src = current(__FILE__).dir('javac/src')
15
+ javac.compile()
16
+ output1.file('org/rubyforge/buildmaster/javac/One.class').should be_exist
17
+ output1.file('org/rubyforge/buildmaster/javac/One.java').should_not be_exist
18
+ output1.file('resource.txt').should be_exist
19
+
20
+ # compile with library
21
+ javac = JavacAnt.new(output2)
22
+ javac.src = current(__FILE__).dir('javac/src2')
23
+ javac.classpath.add output1
24
+ javac.compile()
25
+ output2.file('org/rubyforge/buildmaster/javac/Two.class').should be_exist
26
+ end
27
+
28
+ it 'should copy all resources that are not in src' do
29
+ output = setup_tmp
30
+ javac = JavacAnt.new(output)
31
+ javac.src = current(__FILE__).dir('javac/src')
32
+ javac.resource = current(__FILE__).dir('javac/src2')
33
+ javac.compile
34
+ output.file('org/rubyforge/buildmaster/javac/One.class').should be_exist
35
+ output.file('org/rubyforge/buildmaster/javac/Two.java').should be_exist
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,187 @@
1
+ require File.dirname(__FILE__) + '/../../../lib/buildmaster/auto'
2
+ require 'spec'
3
+
4
+ module BuildMaster
5
+ describe JUnitAnt do
6
+ it 'should create ANT build file, and jvmargs' do
7
+ report = Cotta.new(InMemorySystem.new).dir('report')
8
+ junit = JUnitAnt.new(report).for_test('org.rubyforge.AllTests')
9
+ junit.jvmargs.push('jvmargument')
10
+ junit.generate
11
+ build_file = report.file('junit-ant.xml')
12
+ build_file.load.should == <<RESULT
13
+ <!-- ANT file generated by buildmaste JUnitAnt -->
14
+ <project name="junit-ant" default="junit-ant">
15
+
16
+
17
+ <target name="junit-ant">
18
+
19
+ <junit printsummary="yes" fork="yes" forkmode="perBatch" errorproperty="error" failureproperty="failure" haltonerror="no" haltonfailure="no">
20
+ <formatter type="xml"/>
21
+ <jvmarg line="jvmargument"/>
22
+ <test name="org.rubyforge.AllTests" todir="#{report}/test"/>
23
+ </junit>
24
+ <junitreport todir="#{report}/test">
25
+ <fileset dir="#{report}/test">
26
+ <include name="TEST-*.xml"/>
27
+ </fileset>
28
+ <report todir="#{report}/test" format="frames"/>
29
+ </junitreport>
30
+
31
+ <fail message="test failed">
32
+ <condition>
33
+ <or>
34
+ <isset property="fail"/>
35
+ <isset property="error"/>
36
+ </or>
37
+ </condition>
38
+ </fail>
39
+ </target>
40
+ </project>
41
+ RESULT
42
+ end
43
+
44
+ it 'should create with classpath' do
45
+ report = Cotta.new(InMemorySystem.new).dir('report')
46
+ junit = JUnitAnt.new(report).for_test('AllTests')
47
+ junit.classpath.add(report.file('one'))
48
+ junit.generate(report.file('xml.xml'))
49
+ report.file('xml.xml').load.should == <<RESULT
50
+ <!-- ANT file generated by buildmaste JUnitAnt -->
51
+ <project name="junit-ant" default="junit-ant">
52
+
53
+ <path id="refid">
54
+ <pathelement location="report/one"/>
55
+ </path>
56
+
57
+ <target name="junit-ant">
58
+
59
+ <junit printsummary="yes" fork="yes" forkmode="perBatch" errorproperty="error" failureproperty="failure" haltonerror="no" haltonfailure="no">
60
+ <formatter type="xml"/>
61
+ <classpath refid="refid"/>
62
+ <test name="AllTests" todir="#{report}/test"/>
63
+ </junit>
64
+ <junitreport todir="#{report}/test">
65
+ <fileset dir="#{report}/test">
66
+ <include name="TEST-*.xml"/>
67
+ </fileset>
68
+ <report todir="#{report}/test" format="frames"/>
69
+ </junitreport>
70
+
71
+ <fail message="test failed">
72
+ <condition>
73
+ <or>
74
+ <isset property="fail"/>
75
+ <isset property="error"/>
76
+ </or>
77
+ </condition>
78
+ </fail>
79
+ </target>
80
+ </project>
81
+ RESULT
82
+ end
83
+
84
+ it 'should create with batch test set up' do
85
+ report = Cotta.new(InMemorySystem.new).dir('report')
86
+ project = JavaProject.new(report)
87
+ project.test.src = report.dir('test')
88
+ junit = JUnitAnt.new(report, project).for_tests('**.java')
89
+ junit.generate(report.file('xml.xml'))
90
+ report.file('xml.xml').load.should == <<RESULT
91
+ <!-- ANT file generated by buildmaste JUnitAnt -->
92
+ <project name="junit-ant" default="junit-ant">
93
+
94
+
95
+ <target name="junit-ant">
96
+
97
+ <junit printsummary="yes" fork="yes" forkmode="perBatch" errorproperty="error" failureproperty="failure" haltonerror="no" haltonfailure="no">
98
+ <formatter type="xml"/>
99
+ <batchtest fork="yes" todir="#{report}/test">
100
+ <fileset dir="#{project.test.src}">
101
+ <include name="**/**.java"/>
102
+ </fileset>
103
+ </batchtest>
104
+ </junit>
105
+ <junitreport todir="#{report}/test">
106
+ <fileset dir="#{report}/test">
107
+ <include name="TEST-*.xml"/>
108
+ </fileset>
109
+ <report todir="#{report}/test" format="frames"/>
110
+ </junitreport>
111
+
112
+ <fail message="test failed">
113
+ <condition>
114
+ <or>
115
+ <isset property="fail"/>
116
+ <isset property="error"/>
117
+ </or>
118
+ </condition>
119
+ </fail>
120
+ </target>
121
+ </project>
122
+ RESULT
123
+ end
124
+
125
+ it 'should create tasks for cobertura' do
126
+ report = Cotta.new(InMemorySystem.new).dir('report')
127
+ project = JavaProject.new(report)
128
+ project.src = report.dir('src')
129
+ project.output = report.dir('output')
130
+ junit = JUnitAnt.new(report, project).for_test('All')
131
+ cobertura = report.file('cobertura.jar')
132
+ junit.with_coverage(cobertura)
133
+ junit.generate(report.file('xml.xml'))
134
+ report.file('xml.xml').load.should == <<RESULT
135
+ <!-- ANT file generated by buildmaste JUnitAnt -->
136
+ <project name="junit-ant" default="junit-ant">
137
+ <path id="coverage">
138
+ <pathelement location="report/cobertura.jar"/>
139
+ <fileset dir="report/lib">
140
+ <include name="**/*.jar"/>
141
+ </fileset>
142
+ </path>
143
+ <taskdef classpathref="coverage" resource="tasks.properties"/>
144
+
145
+ <path id="refid">
146
+ <pathelement location="report/output/instrumented"/>
147
+ <pathelement location="report/cobertura.jar"/>
148
+ </path>
149
+
150
+ <target name="junit-ant">
151
+ <cobertura-instrument todir="report/output/instrumented" datafile="report/output/cobertuna.ser">
152
+ <fileset dir="report/output/prod">
153
+ <include name="**/*.class"/>
154
+ </fileset>
155
+ </cobertura-instrument>
156
+ <copy todir="report/output/instrumented">
157
+ <fileset dir="report/output/prod" excludes="**/*.class"/>
158
+ </copy>
159
+
160
+ <junit printsummary="yes" fork="yes" forkmode="perBatch" errorproperty="error" failureproperty="failure" haltonerror="no" haltonfailure="no">
161
+ <formatter type="xml"/>
162
+ <sysproperty key="net.sourceforge.cobertura.datafile" file="report/output/cobertuna.ser" />
163
+ <classpath refid="refid"/>
164
+ <test name="All" todir="report/test"/>
165
+ </junit>
166
+ <junitreport todir="report/test">
167
+ <fileset dir="report/test">
168
+ <include name="TEST-*.xml"/>
169
+ </fileset>
170
+ <report todir="report/test" format="frames"/>
171
+ </junitreport>
172
+ <cobertura-report srcdir="report/src" destdir="report/coverage" datafile="report/output/cobertuna.ser"/>
173
+
174
+ <fail message="test failed">
175
+ <condition>
176
+ <or>
177
+ <isset property="fail"/>
178
+ <isset property="error"/>
179
+ </or>
180
+ </condition>
181
+ </fail>
182
+ </target>
183
+ </project>
184
+ RESULT
185
+ end
186
+ end
187
+ end