mguymon-buildr 1.4.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/CHANGELOG +1291 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +44 -0
  6. data/_buildr +35 -0
  7. data/_jbuildr +35 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/bnd.rb +147 -0
  10. data/addon/buildr/cobertura.rb +22 -0
  11. data/addon/buildr/drb.rb +281 -0
  12. data/addon/buildr/emma.rb +22 -0
  13. data/addon/buildr/hibernate.rb +149 -0
  14. data/addon/buildr/javacc.rb +85 -0
  15. data/addon/buildr/jaxb_xjc.rb +72 -0
  16. data/addon/buildr/jdepend.rb +60 -0
  17. data/addon/buildr/jetty.rb +248 -0
  18. data/addon/buildr/jibx.rb +86 -0
  19. data/addon/buildr/nailgun.rb +221 -0
  20. data/addon/buildr/openjpa.rb +88 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  23. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  27. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  28. data/addon/buildr/protobuf.rb +88 -0
  29. data/addon/buildr/xmlbeans.rb +93 -0
  30. data/bin/buildr +19 -0
  31. data/buildr.buildfile +58 -0
  32. data/buildr.gemspec +78 -0
  33. data/doc/_config.yml +1 -0
  34. data/doc/_layouts/default.html +90 -0
  35. data/doc/_layouts/preface.html +22 -0
  36. data/doc/artifacts.textile +217 -0
  37. data/doc/building.textile +276 -0
  38. data/doc/contributing.textile +268 -0
  39. data/doc/css/default.css +236 -0
  40. data/doc/css/print.css +101 -0
  41. data/doc/css/syntax.css +23 -0
  42. data/doc/download.textile +151 -0
  43. data/doc/extending.textile +212 -0
  44. data/doc/images/1442160941-frontcover.jpg +0 -0
  45. data/doc/images/asf-logo.gif +0 -0
  46. data/doc/images/asf-logo.png +0 -0
  47. data/doc/images/buildr-hires.png +0 -0
  48. data/doc/images/buildr.png +0 -0
  49. data/doc/images/favicon.png +0 -0
  50. data/doc/images/growl-icon.tiff +0 -0
  51. data/doc/images/note.png +0 -0
  52. data/doc/images/project-structure.png +0 -0
  53. data/doc/images/tip.png +0 -0
  54. data/doc/images/zbuildr.png +0 -0
  55. data/doc/images/zbuildr.tif +0 -0
  56. data/doc/index.textile +109 -0
  57. data/doc/installing.textile +284 -0
  58. data/doc/languages.textile +599 -0
  59. data/doc/mailing_lists.textile +29 -0
  60. data/doc/more_stuff.textile +845 -0
  61. data/doc/packaging.textile +618 -0
  62. data/doc/preface.textile +54 -0
  63. data/doc/projects.textile +276 -0
  64. data/doc/quick_start.textile +210 -0
  65. data/doc/releasing.textile +117 -0
  66. data/doc/scripts/buildr-git.rb +512 -0
  67. data/doc/scripts/gitflow.rb +296 -0
  68. data/doc/scripts/install-jruby.sh +44 -0
  69. data/doc/scripts/install-linux.sh +73 -0
  70. data/doc/scripts/install-osx.sh +52 -0
  71. data/doc/settings_profiles.textile +287 -0
  72. data/doc/testing.textile +247 -0
  73. data/etc/KEYS +189 -0
  74. data/lib/buildr.rb +44 -0
  75. data/lib/buildr/clojure.rb +34 -0
  76. data/lib/buildr/clojure/shell.rb +52 -0
  77. data/lib/buildr/core.rb +34 -0
  78. data/lib/buildr/core/application.rb +700 -0
  79. data/lib/buildr/core/build.rb +516 -0
  80. data/lib/buildr/core/cc.rb +166 -0
  81. data/lib/buildr/core/checks.rb +253 -0
  82. data/lib/buildr/core/common.rb +151 -0
  83. data/lib/buildr/core/compile.rb +622 -0
  84. data/lib/buildr/core/doc.rb +276 -0
  85. data/lib/buildr/core/environment.rb +129 -0
  86. data/lib/buildr/core/filter.rb +404 -0
  87. data/lib/buildr/core/generate.rb +197 -0
  88. data/lib/buildr/core/help.rb +119 -0
  89. data/lib/buildr/core/jrebel.rb +42 -0
  90. data/lib/buildr/core/linux.rb +30 -0
  91. data/lib/buildr/core/osx.rb +46 -0
  92. data/lib/buildr/core/progressbar.rb +161 -0
  93. data/lib/buildr/core/project.rb +975 -0
  94. data/lib/buildr/core/run.rb +43 -0
  95. data/lib/buildr/core/shell.rb +137 -0
  96. data/lib/buildr/core/test.rb +843 -0
  97. data/lib/buildr/core/transports.rb +575 -0
  98. data/lib/buildr/core/util.rb +537 -0
  99. data/lib/buildr/groovy.rb +20 -0
  100. data/lib/buildr/groovy/bdd.rb +106 -0
  101. data/lib/buildr/groovy/compiler.rb +153 -0
  102. data/lib/buildr/groovy/doc.rb +76 -0
  103. data/lib/buildr/groovy/shell.rb +57 -0
  104. data/lib/buildr/ide.rb +19 -0
  105. data/lib/buildr/ide/eclipse.rb +427 -0
  106. data/lib/buildr/ide/eclipse/java.rb +53 -0
  107. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  108. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  109. data/lib/buildr/ide/idea.rb +576 -0
  110. data/lib/buildr/java.rb +25 -0
  111. data/lib/buildr/java/ant.rb +94 -0
  112. data/lib/buildr/java/bdd.rb +460 -0
  113. data/lib/buildr/java/cobertura.rb +297 -0
  114. data/lib/buildr/java/commands.rb +223 -0
  115. data/lib/buildr/java/compiler.rb +135 -0
  116. data/lib/buildr/java/deprecated.rb +141 -0
  117. data/lib/buildr/java/doc.rb +86 -0
  118. data/lib/buildr/java/ecj.rb +69 -0
  119. data/lib/buildr/java/emma.rb +244 -0
  120. data/lib/buildr/java/external.rb +73 -0
  121. data/lib/buildr/java/jruby.rb +122 -0
  122. data/lib/buildr/java/jtestr_result.rb +295 -0
  123. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  124. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  125. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  126. data/lib/buildr/java/packaging.rb +734 -0
  127. data/lib/buildr/java/pom.rb +178 -0
  128. data/lib/buildr/java/rjb.rb +154 -0
  129. data/lib/buildr/java/test_result.rb +101 -0
  130. data/lib/buildr/java/tests.rb +362 -0
  131. data/lib/buildr/java/version_requirement.rb +172 -0
  132. data/lib/buildr/packaging.rb +25 -0
  133. data/lib/buildr/packaging/archive.rb +535 -0
  134. data/lib/buildr/packaging/artifact.rb +904 -0
  135. data/lib/buildr/packaging/artifact_namespace.rb +984 -0
  136. data/lib/buildr/packaging/artifact_search.rb +140 -0
  137. data/lib/buildr/packaging/gems.rb +105 -0
  138. data/lib/buildr/packaging/package.rb +249 -0
  139. data/lib/buildr/packaging/repository_array.rb +108 -0
  140. data/lib/buildr/packaging/tar.rb +189 -0
  141. data/lib/buildr/packaging/version_requirement.rb +192 -0
  142. data/lib/buildr/packaging/zip.rb +178 -0
  143. data/lib/buildr/packaging/ziptask.rb +356 -0
  144. data/lib/buildr/resources/buildr.icns +0 -0
  145. data/lib/buildr/resources/completed.png +0 -0
  146. data/lib/buildr/resources/failed.png +0 -0
  147. data/lib/buildr/resources/icons-license.txt +17 -0
  148. data/lib/buildr/run.rb +195 -0
  149. data/lib/buildr/scala.rb +26 -0
  150. data/lib/buildr/scala/bdd.rb +118 -0
  151. data/lib/buildr/scala/compiler.rb +242 -0
  152. data/lib/buildr/scala/doc.rb +142 -0
  153. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  154. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  155. data/lib/buildr/scala/shell.rb +52 -0
  156. data/lib/buildr/scala/tests.rb +171 -0
  157. data/lib/buildr/shell.rb +185 -0
  158. data/lib/buildr/version.rb +18 -0
  159. data/rakelib/all-in-one.rake +113 -0
  160. data/rakelib/checks.rake +57 -0
  161. data/rakelib/doc.rake +137 -0
  162. data/rakelib/metrics.rake +39 -0
  163. data/rakelib/package.rake +73 -0
  164. data/rakelib/release.rake +160 -0
  165. data/rakelib/rspec.rake +91 -0
  166. data/rakelib/setup.rake +66 -0
  167. data/rakelib/stage.rake +220 -0
  168. data/spec/addon/bnd_spec.rb +330 -0
  169. data/spec/addon/drb_spec.rb +328 -0
  170. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  171. data/spec/core/application_spec.rb +631 -0
  172. data/spec/core/build_spec.rb +837 -0
  173. data/spec/core/cc_spec.rb +224 -0
  174. data/spec/core/checks_spec.rb +519 -0
  175. data/spec/core/common_spec.rb +725 -0
  176. data/spec/core/compile_spec.rb +658 -0
  177. data/spec/core/doc_spec.rb +195 -0
  178. data/spec/core/extension_spec.rb +201 -0
  179. data/spec/core/generate_spec.rb +33 -0
  180. data/spec/core/project_spec.rb +772 -0
  181. data/spec/core/run_spec.rb +93 -0
  182. data/spec/core/shell_spec.rb +146 -0
  183. data/spec/core/test_spec.rb +1320 -0
  184. data/spec/core/transport_spec.rb +544 -0
  185. data/spec/core/util_spec.rb +141 -0
  186. data/spec/groovy/bdd_spec.rb +80 -0
  187. data/spec/groovy/compiler_spec.rb +251 -0
  188. data/spec/groovy/doc_spec.rb +65 -0
  189. data/spec/ide/eclipse_spec.rb +739 -0
  190. data/spec/ide/idea_spec.rb +1145 -0
  191. data/spec/java/ant_spec.rb +37 -0
  192. data/spec/java/bdd_spec.rb +374 -0
  193. data/spec/java/cobertura_spec.rb +112 -0
  194. data/spec/java/commands_spec.rb +93 -0
  195. data/spec/java/compiler_spec.rb +252 -0
  196. data/spec/java/doc_spec.rb +56 -0
  197. data/spec/java/ecj_spec.rb +115 -0
  198. data/spec/java/emma_spec.rb +121 -0
  199. data/spec/java/external_spec.rb +56 -0
  200. data/spec/java/java_spec.rb +132 -0
  201. data/spec/java/packaging_spec.rb +1266 -0
  202. data/spec/java/run_spec.rb +78 -0
  203. data/spec/java/test_coverage_helper.rb +257 -0
  204. data/spec/java/tests_spec.rb +497 -0
  205. data/spec/packaging/archive_spec.rb +775 -0
  206. data/spec/packaging/artifact_namespace_spec.rb +743 -0
  207. data/spec/packaging/artifact_spec.rb +1074 -0
  208. data/spec/packaging/packaging_helper.rb +63 -0
  209. data/spec/packaging/packaging_spec.rb +719 -0
  210. data/spec/packaging/repository_array_spec.rb +109 -0
  211. data/spec/sandbox.rb +165 -0
  212. data/spec/scala/bdd_spec.rb +124 -0
  213. data/spec/scala/compiler_spec.rb +289 -0
  214. data/spec/scala/doc_spec.rb +88 -0
  215. data/spec/scala/scala.rb +38 -0
  216. data/spec/scala/tests_spec.rb +283 -0
  217. data/spec/spec_helpers.rb +369 -0
  218. data/spec/version_requirement_spec.rb +143 -0
  219. data/spec/xpath_matchers.rb +121 -0
  220. metadata +600 -0
@@ -0,0 +1,224 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+ module CCHelper
20
+
21
+ # monkey-patch task instance to track number of times it is run
22
+ def instrument_task(task)
23
+ class << task
24
+ attr_accessor :run_count
25
+ end
26
+ task.run_count = 0
27
+ task.enhance do |t|
28
+ t.run_count += 1
29
+ end
30
+ task
31
+ end
32
+
33
+ def instrument_project(project)
34
+ instrument_task project.compile
35
+ instrument_task project.test.compile
36
+ instrument_task project.resources
37
+ project
38
+ end
39
+
40
+ def define_foo()
41
+ @foo = define('foo')
42
+ instrument_project @foo
43
+ @foo
44
+ end
45
+
46
+ def foo()
47
+ @foo
48
+ end
49
+ end
50
+
51
+
52
+ describe Buildr::CCTask do
53
+ include CCHelper
54
+
55
+ it 'should default to a delay of 0.2' do
56
+ define('foo').cc.delay.should == 0.2
57
+ end
58
+
59
+ it 'should compile and test:compile on initial start' do
60
+ ['Test1.java', 'Test2.java'].map { |f| File.join('src/main/java/thepackage', f) }.
61
+ each { |src| write src, "package thepackage; class #{src.pathmap('%n')} {}" }
62
+
63
+ ['Test1.java', 'Test2.java'].map { |f| File.join('src/test/java/thepackage', f) }.
64
+ each { |src| write src, "package thepackage; class #{src.pathmap('%n')} {}" }
65
+
66
+ ['Test1.html', 'Test2.html'].map { |f| File.join('src/main/resources', f) }.
67
+ each { |src| write src, '<html></html>' }
68
+
69
+ define_foo()
70
+
71
+ thread = Thread.new do
72
+ foo.cc.invoke
73
+ end
74
+
75
+ sleep 1
76
+
77
+ foo.compile.run_count.should == 1
78
+ foo.test.compile.run_count.should == 1
79
+
80
+ thread.exit
81
+ end
82
+
83
+ it 'should detect a file change' do |spec|
84
+ write 'src/main/resources/my.properties', "# comment"
85
+ write 'src/main/java/Example.java', "public class Example {}"
86
+ write 'src/test/java/ExampleTest.java', "public class ExampleTest {}"
87
+
88
+ define_foo
89
+
90
+ thread = Thread.new do
91
+ begin
92
+ foo.cc.invoke
93
+ rescue => e
94
+ p "unexpected exception #{e.inspect}"
95
+ p e.backtrace.join("\n").inspect
96
+ end
97
+ end
98
+
99
+ sleep 1
100
+
101
+ foo.compile.run_count.should == 1
102
+ foo.test.compile.run_count.should == 1
103
+ foo.resources.run_count.should == 1
104
+
105
+ sleep 1 # Wait one sec as the timestamp needs to be different.
106
+
107
+ touch File.join(Dir.pwd, 'src/main/java/Example.java')
108
+
109
+ sleep 1
110
+
111
+ foo.compile.run_count.should == 2
112
+ foo.test.compile.run_count.should == 2
113
+ foo.resources.run_count.should == 2
114
+
115
+ thread.exit
116
+ end
117
+
118
+ it 'should support subprojects' do |spec|
119
+ write 'foo/src/main/java/Example.java', "public class Example {}"
120
+ write 'foo/src/test/java/ExampleTest.java', "public class ExampleTest {}"
121
+
122
+ define 'container' do
123
+ define('foo')
124
+ end
125
+
126
+ foo = instrument_project project("container:foo")
127
+
128
+ thread = Thread.new do
129
+ begin
130
+ project("container").cc.invoke
131
+ rescue => e
132
+ p "unexpected exception #{e.inspect}"
133
+ p e.backtrace.join("\n").inspect
134
+ end
135
+ end
136
+
137
+ sleep 1
138
+
139
+ foo.compile.run_count.should == 1
140
+ foo.test.compile.run_count.should == 1
141
+ foo.resources.run_count.should == 1
142
+
143
+ file("foo/target/classes/Example.class").should exist
144
+ tstamp = File.mtime("foo/target/classes/Example.class")
145
+ touch File.join(Dir.pwd, 'foo/src/main/java/Example.java')
146
+
147
+ sleep 1
148
+
149
+ foo.compile.run_count.should == 2
150
+ foo.test.compile.run_count.should == 2
151
+ foo.resources.run_count.should == 2
152
+ File.mtime("foo/target/classes/Example.class").should_not == tstamp
153
+
154
+ thread.exit
155
+ end
156
+
157
+ it 'should support parent and subprojects' do |spec|
158
+ write 'foo/src/main/java/Example.java', "public class Example {}"
159
+ write 'foo/src/test/java/ExampleTest.java', "public class ExampleTest {}"
160
+
161
+ write 'bar/src/main/java/Example.java', "public class Example {}"
162
+ write 'bar/src/test/java/ExampleTest.java', "public class ExampleTest {}"
163
+
164
+ write 'src/main/java/Example.java', "public class Example {}"
165
+ write 'src/test/java/ExampleTest.java', "public class ExampleTest {}"
166
+
167
+ write 'src/main/resources/foo.txt', "content"
168
+
169
+ define 'container' do
170
+ define('foo')
171
+ define('bar')
172
+ end
173
+
174
+ all = projects("container", "container:foo", "container:bar")
175
+ all.each { |p| instrument_project(p) }
176
+
177
+ thread = Thread.new do
178
+ begin
179
+ project("container").cc.invoke
180
+ rescue => e
181
+ p "unexpected exception #{e.inspect}"
182
+ p e.backtrace.join("\n").inspect
183
+ end
184
+ end
185
+
186
+ sleep 2
187
+
188
+ all.each do |p|
189
+ p.compile.run_count.should == 1
190
+ p.test.compile.run_count.should == 1
191
+ p.resources.run_count.should == 1
192
+ end
193
+
194
+ file("foo/target/classes/Example.class").should exist
195
+ tstamp = File.mtime("foo/target/classes/Example.class")
196
+
197
+ touch 'foo/src/main/java/Example.java'
198
+ p "after touch"
199
+ sleep 2
200
+
201
+ project("container:foo").tap do |p|
202
+ p.compile.run_count.should == 2
203
+ p.test.compile.run_count.should == 2
204
+ p.resources.run_count.should == 2
205
+ end
206
+ project("container").tap do |p|
207
+ p.compile.run_count.should == 1 # not_needed
208
+ p.test.compile.run_count.should == 1 # not_needed
209
+ p.resources.run_count.should == 2
210
+ end
211
+ File.mtime("foo/target/classes/Example.class").should_not == tstamp
212
+
213
+ touch 'src/main/java/Example.java'
214
+ sleep 2
215
+
216
+ project("container").tap do |p|
217
+ p.compile.run_count.should == 2
218
+ p.test.compile.run_count.should == 2
219
+ p.resources.run_count.should == 3
220
+ end
221
+
222
+ thread.exit
223
+ end
224
+ end
@@ -0,0 +1,519 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+
20
+ describe Project, 'check task' do
21
+
22
+ it "should execute last thing from package task" do
23
+ task 'action'
24
+ define 'foo', :version=>'1.0' do
25
+ package :jar
26
+ task('package').enhance { task('action').invoke }
27
+ end
28
+ lambda { project('foo').task('package').invoke }.should run_tasks(['foo:package', 'action', 'foo:check'])
29
+ end
30
+
31
+ it "should execute all project's expectations" do
32
+ task 'expectation'
33
+ define 'foo', :version=>'1.0' do
34
+ check { task('expectation').invoke }
35
+ end
36
+ lambda { project('foo').task('package').invoke }.should run_task('expectation')
37
+ end
38
+
39
+ it "should succeed if there are no expectations" do
40
+ define 'foo', :version=>'1.0'
41
+ lambda { project('foo').task('package').invoke }.should_not raise_error
42
+ end
43
+
44
+ it "should succeed if all expectations passed" do
45
+ define 'foo', :version=>'1.0' do
46
+ check { true }
47
+ check { false }
48
+ end
49
+ lambda { project('foo').task('package').invoke }.should_not raise_error
50
+ end
51
+
52
+ it "should fail if any expectation failed" do
53
+ define 'foo', :version=>'1.0' do
54
+ check
55
+ check { fail 'sorry' }
56
+ check
57
+ end
58
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
59
+ end
60
+ end
61
+
62
+
63
+ describe Project, '#check' do
64
+
65
+ it "should add expectation" do
66
+ define 'foo' do
67
+ expectations.should be_empty
68
+ check
69
+ expectations.size.should be(1)
70
+ end
71
+ end
72
+
73
+ it "should treat no arguments as expectation against project" do
74
+ define 'foo' do
75
+ subject = self
76
+ check do
77
+ it.should be(subject)
78
+ description.should eql(subject.to_s)
79
+ end
80
+ end
81
+ lambda { project('foo').task('package').invoke }.should_not raise_error
82
+ end
83
+
84
+ it "should treat single string argument as description, expectation against project" do
85
+ define 'foo' do
86
+ subject = self
87
+ check "should be project" do
88
+ it.should be(subject)
89
+ description.should eql("#{subject} should be project")
90
+ end
91
+ end
92
+ lambda { project('foo').task('package').invoke }.should_not raise_error
93
+ end
94
+
95
+ it "should treat single object argument as subject" do
96
+ define 'foo' do
97
+ subject = Object.new
98
+ check subject do
99
+ it.should be(subject)
100
+ description.should eql(subject.to_s)
101
+ end
102
+ end
103
+ lambda { project('foo').task('package').invoke }.should_not raise_error
104
+ end
105
+
106
+ it "should treat first object as subject, second object as description" do
107
+ define 'foo' do
108
+ subject = Object.new
109
+ check subject, "should exist" do
110
+ it.should be(subject)
111
+ description.should eql("#{subject} should exist")
112
+ end
113
+ end
114
+ lambda { project('foo').task('package').invoke }.should_not raise_error
115
+ end
116
+
117
+ it "should work without block" do
118
+ define 'foo' do
119
+ check "implement later"
120
+ end
121
+ lambda { project('foo').task('package').invoke }.should_not raise_error
122
+ end
123
+
124
+ it 'should pass method calls to context' do
125
+ define 'foo', :version=>'1.0' do
126
+ subject = self
127
+ check "should be project" do
128
+ it.should be(subject)
129
+ name.should eql(subject.name)
130
+ package(:jar).should eql(subject.package(:jar))
131
+ end
132
+ end
133
+ lambda { project('foo').task('package').invoke }.should_not raise_error
134
+ end
135
+ end
136
+
137
+
138
+ describe Buildr::Checks::Expectation, 'matchers' do
139
+
140
+ it "should include Buildr matchers exist and contain" do
141
+ define 'foo' do
142
+ check do
143
+ self.should respond_to(:exist)
144
+ self.should respond_to(:contain)
145
+ end
146
+ end
147
+ lambda { project('foo').task('package').invoke }.should_not raise_error
148
+ end
149
+
150
+ it "should include RSpec matchers like be and eql" do
151
+ define 'foo' do
152
+ check do
153
+ self.should respond_to(:be)
154
+ self.should respond_to(:eql)
155
+ end
156
+ end
157
+ lambda { project('foo').task('package').invoke }.should_not raise_error
158
+ end
159
+
160
+ it "should include RSpec predicates like be_nil and be_empty" do
161
+ define 'foo' do
162
+ check do
163
+ nil.should be_nil
164
+ [].should be_empty
165
+ end
166
+ end
167
+ lambda { project('foo').task('package').invoke }.should_not raise_error
168
+ end
169
+ end
170
+
171
+
172
+ describe Buildr::Checks::Expectation, 'exist' do
173
+
174
+ it "should pass if file exists" do
175
+ define 'foo' do
176
+ build file('test') { |task| write task.name }
177
+ check(file('test')) { it.should exist }
178
+ end
179
+ lambda { project('foo').task('package').invoke }.should_not raise_error
180
+ end
181
+
182
+ it "should fail if file does not exist" do
183
+ define 'foo' do
184
+ check(file('test')) { it.should exist }
185
+ end
186
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
187
+ end
188
+
189
+ it "should not attempt to invoke task" do
190
+ define 'foo' do
191
+ file('test') { |task| write task.name }
192
+ check(file('test')) { it.should exist }
193
+ end
194
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
195
+ end
196
+ end
197
+
198
+
199
+ describe Buildr::Checks::Expectation, " be_empty" do
200
+
201
+ it "should pass if file has no content" do
202
+ define 'foo' do
203
+ build file('test') { write 'test' }
204
+ check(file('test')) { it.should be_empty }
205
+ end
206
+ lambda { project('foo').task('package').invoke }.should_not raise_error
207
+ end
208
+
209
+ it "should fail if file has content" do
210
+ define 'foo' do
211
+ build file('test') { write 'test', "something" }
212
+ check(file('test')) { it.should be_empty }
213
+ end
214
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
215
+ end
216
+
217
+ it "should fail if file does not exist" do
218
+ define 'foo' do
219
+ check(file('test')) { it.should be_empty }
220
+ end
221
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
222
+ end
223
+
224
+ it "should pass if directory is empty" do
225
+ define 'foo' do
226
+ build file('test') { mkpath 'test' }
227
+ check(file('test')) { it.should be_empty }
228
+ end
229
+ lambda { project('foo').task('package').invoke }.should_not raise_error
230
+ end
231
+
232
+ it "should fail if directory has any files" do
233
+ define 'foo' do
234
+ build file('test') { write 'test/file' }
235
+ check(file('test')) { it.should be_empty }
236
+ end
237
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
238
+ end
239
+ end
240
+
241
+
242
+ describe Buildr::Checks::Expectation, " contain(file)" do
243
+
244
+ it "should pass if file content matches string" do
245
+ define 'foo' do
246
+ build file('test') { write 'test', 'something' }
247
+ check(file('test')) { it.should contain('thing') }
248
+ end
249
+ lambda { project('foo').task('package').invoke }.should_not raise_error
250
+ end
251
+
252
+ it "should pass if file content matches pattern" do
253
+ define 'foo' do
254
+ build file('test') { write 'test', "something\nor\nanother" }
255
+ check(file('test')) { it.should contain(/or/) }
256
+ end
257
+ lambda { project('foo').task('package').invoke }.should_not raise_error
258
+ end
259
+
260
+ it "should pass if file content matches all arguments" do
261
+ define 'foo' do
262
+ build file('test') { write 'test', "something\nor\nanother" }
263
+ check(file('test')) { it.should contain(/or/, /other/) }
264
+ end
265
+ lambda { project('foo').task('package').invoke }.should_not raise_error
266
+ end
267
+
268
+ it "should fail unless file content matchs all arguments" do
269
+ define 'foo' do
270
+ build file('test') { write 'test', 'something' }
271
+ check(file('test')) { it.should contain(/some/, /other/) }
272
+ end
273
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
274
+ end
275
+
276
+ it "should fail if file content does not match" do
277
+ define 'foo' do
278
+ build file('test') { write 'test', "something" }
279
+ check(file('test')) { it.should contain(/other/) }
280
+ end
281
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
282
+ end
283
+
284
+ it "should fail if file does not exist" do
285
+ define 'foo' do
286
+ check(file('test')) { it.should contain(/anything/) }
287
+ end
288
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
289
+ end
290
+ end
291
+
292
+
293
+ describe Buildr::Checks::Expectation, 'contain(directory)' do
294
+
295
+ it "should pass if directory contains file" do
296
+ write 'resources/test'
297
+ define 'foo' do
298
+ check(file('resources')) { it.should contain('test') }
299
+ end
300
+ lambda { project('foo').task('package').invoke }.should_not raise_error
301
+ end
302
+
303
+ it "should pass if directory contains glob pattern" do
304
+ write 'resources/with/test'
305
+ define 'foo' do
306
+ check(file('resources')) { it.should contain('**/t*st') }
307
+ end
308
+ lambda { project('foo').task('package').invoke }.should_not raise_error
309
+ end
310
+
311
+ it "should pass if directory contains all arguments" do
312
+ write 'resources/with/test'
313
+ define 'foo' do
314
+ check(file('resources')) { it.should contain('**/test', '**/*') }
315
+ end
316
+ lambda { project('foo').task('package').invoke }.should_not raise_error
317
+ end
318
+
319
+ it "should fail unless directory contains all arguments" do
320
+ write 'resources/test'
321
+ define 'foo' do
322
+ check(file('resources')) { it.should contain('test', 'or-not') }
323
+ end
324
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
325
+ end
326
+
327
+ it "should fail if directory is empty" do
328
+ mkpath 'resources'
329
+ define 'foo' do
330
+ check(file('resources')) { it.should contain('test') }
331
+ end
332
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
333
+ end
334
+
335
+ it "should fail if directory does not exist" do
336
+ define 'foo' do
337
+ check(file('resources')) { it.should contain }
338
+ end
339
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
340
+ end
341
+ end
342
+
343
+
344
+ describe Buildr::Checks::Expectation do
345
+
346
+ shared_examples_for 'all archive types' do
347
+
348
+ before do
349
+ archive = @archive
350
+ define 'foo', :version=>'1.0' do
351
+ package(archive).include('resources')
352
+ end
353
+ end
354
+
355
+ def check *args, &block
356
+ project('foo').check *args, &block
357
+ end
358
+
359
+ def package
360
+ project('foo').package(@archive)
361
+ end
362
+
363
+ describe '#exist' do
364
+
365
+ it "should pass if archive path exists" do
366
+ write 'resources/test'
367
+ check(package.path('resources')) { it.should exist }
368
+ lambda { project('foo').task('package').invoke }.should_not raise_error
369
+ end
370
+
371
+ it "should fail if archive path does not exist" do
372
+ mkpath 'resources'
373
+ check(package) { it.path('not-resources').should exist }
374
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
375
+ end
376
+
377
+ it "should pass if archive entry exists" do
378
+ write 'resources/test'
379
+ check(package.entry('resources/test')) { it.should exist }
380
+ check(package.path('resources').entry('test')) { it.should exist }
381
+ lambda { project('foo').task('package').invoke }.should_not raise_error
382
+ end
383
+
384
+ it "should fail if archive path does not exist" do
385
+ mkpath 'resources'
386
+ check(package.entry('resources/test')) { it.should exist }
387
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
388
+ end
389
+ end
390
+
391
+ describe '#be_empty' do
392
+ it "should pass if archive path is empty" do
393
+ mkpath 'resources'
394
+ check(package.path('resources')) { it.should be_empty }
395
+ lambda { project('foo').task('package').invoke }.should_not raise_error
396
+ end
397
+
398
+ it "should fail if archive path has any entries" do
399
+ write 'resources/test'
400
+ check(package.path('resources')) { it.should be_empty }
401
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
402
+ end
403
+
404
+ it "should pass if archive entry has no content" do
405
+ write 'resources/test'
406
+ check(package.entry('resources/test')) { it.should be_empty }
407
+ check(package.path('resources').entry('test')) { it.should be_empty }
408
+ lambda { project('foo').task('package').invoke }.should_not raise_error
409
+ end
410
+
411
+ it "should fail if archive entry has content" do
412
+ write 'resources/test', 'something'
413
+ check(package.entry('resources/test')) { it.should be_empty }
414
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
415
+ end
416
+
417
+ it "should fail if archive entry does not exist" do
418
+ mkpath 'resources'
419
+ check(package.entry('resources/test')) { it.should be_empty }
420
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
421
+ end
422
+ end
423
+
424
+ describe '#contain(entry)' do
425
+
426
+ it "should pass if archive entry content matches string" do
427
+ write 'resources/test', 'something'
428
+ check(package.entry('resources/test')) { it.should contain('thing') }
429
+ lambda { project('foo').task('package').invoke }.should_not raise_error
430
+ end
431
+
432
+ it "should pass if archive entry content matches pattern" do
433
+ write 'resources/test', "something\nor\another"
434
+ check(package.entry('resources/test')) { it.should contain(/or/) }
435
+ lambda { project('foo').task('package').invoke }.should_not raise_error
436
+ end
437
+
438
+ it "should pass if archive entry content matches all arguments" do
439
+ write 'resources/test', "something\nor\nanother"
440
+ check(package.entry('resources/test')) { it.should contain(/or/, /other/) }
441
+ lambda { project('foo').task('package').invoke }.should_not raise_error
442
+ end
443
+
444
+ it "should fail unless archive path contains all arguments" do
445
+ write 'resources/test', 'something'
446
+ check(package.entry('resources/test')) { it.should contain(/some/, /other/) }
447
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
448
+ end
449
+
450
+ it "should fail if archive entry content does not match" do
451
+ write 'resources/test', 'something'
452
+ check(package.entry('resources/test')) { it.should contain(/other/) }
453
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
454
+ end
455
+
456
+ it "should fail if archive entry does not exist" do
457
+ mkpath 'resources'
458
+ check(package.entry('resources/test')) { it.should contain(/anything/) }
459
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
460
+ end
461
+ end
462
+
463
+ describe '#contain(path)' do
464
+
465
+ it "should pass if archive path contains file" do
466
+ write 'resources/test'
467
+ check(package.path('resources')) { it.should contain('test') }
468
+ lambda { project('foo').task('package').invoke }.should_not raise_error
469
+ end
470
+
471
+ it "should handle deep nesting" do
472
+ write 'resources/test/test2.efx'
473
+ check(package) { it.should contain('resources/test/test2.efx') }
474
+ check(package.path('resources')) { it.should contain('test/test2.efx') }
475
+ check(package.path('resources/test')) { it.should contain('test2.efx') }
476
+ lambda { project('foo').task('package').invoke }.should_not raise_error
477
+ end
478
+
479
+ it "should pass if archive path contains pattern" do
480
+ write 'resources/with/test'
481
+ check(package.path('resources')) { it.should contain('**/t*st') }
482
+ lambda { project('foo').task('package').invoke }.should_not raise_error
483
+ end
484
+
485
+ it "should pass if archive path contains all arguments" do
486
+ write 'resources/with/test'
487
+ check(package.path('resources')) { it.should contain('**/test', '**/*') }
488
+ lambda { project('foo').task('package').invoke }.should_not raise_error
489
+ end
490
+
491
+ it "should fail unless archive path contains all arguments" do
492
+ write 'resources/test'
493
+ check(package.path('resources')) { it.should contain('test', 'or-not') }
494
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
495
+ end
496
+
497
+ it "should fail if archive path is empty" do
498
+ mkpath 'resources'
499
+ check(package.path('resources')) { it.should contain('test') }
500
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
501
+ end
502
+ end
503
+ end
504
+
505
+ describe 'ZIP' do
506
+ before { @archive = :jar }
507
+ it_should_behave_like 'all archive types'
508
+ end
509
+
510
+ describe 'tar' do
511
+ before { @archive = :tar }
512
+ it_should_behave_like 'all archive types'
513
+ end
514
+
515
+ describe 'tgz' do
516
+ before { @archive = :tgz }
517
+ it_should_behave_like 'all archive types'
518
+ end
519
+ end