buildr 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +66 -4
- data/{README → README.rdoc} +29 -16
- data/Rakefile +16 -20
- data/_buildr +38 -0
- data/addon/buildr/cobertura.rb +49 -45
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +585 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +21 -14
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -323
- data/doc/pages/contributing.textile +112 -102
- data/doc/pages/download.textile +19 -27
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +44 -119
- data/doc/pages/index.textile +26 -47
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +71 -239
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +69 -167
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/site.haml +1 -0
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -5
- data/lib/buildr/core/application.rb +192 -98
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +12 -10
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -9
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +51 -26
- data/lib/buildr/core/transports.rb +22 -38
- data/lib/buildr/core/util.rb +78 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +7 -8
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +9 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +71 -45
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +3 -2
- data/rakelib/rspec.rake +23 -21
- data/rakelib/setup.rake +34 -9
- data/rakelib/stage.rake +4 -1
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/core/generate_spec.rb +33 -0
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
- data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +22 -5
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
- data/spec/spec_helpers.rb +38 -17
- metadata +103 -70
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/lib/buildr/java/test_frameworks.rb +0 -450
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
@@ -14,7 +14,7 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
18
|
|
19
19
|
|
20
20
|
describe URI, '#download' do
|
@@ -373,16 +373,12 @@ describe URI::HTTP, '#write' do
|
|
373
373
|
end
|
374
374
|
|
375
375
|
it 'should fail on 4xx response' do
|
376
|
-
@http.should_receive(:request)
|
377
|
-
Net::HTTPBadRequest.new(nil, nil, nil)
|
378
|
-
end
|
376
|
+
@http.should_receive(:request).and_return(Net::HTTPBadRequest.new(nil, nil, nil))
|
379
377
|
lambda { @uri.write @content }.should raise_error(RuntimeError, /failed to upload/i)
|
380
378
|
end
|
381
379
|
|
382
380
|
it 'should fail on 5xx response' do
|
383
|
-
@http.should_receive(:request)
|
384
|
-
Net::HTTPServiceUnavailable.new(nil, nil, nil)
|
385
|
-
end
|
381
|
+
@http.should_receive(:request).and_return(Net::HTTPServiceUnavailable.new(nil, nil, nil))
|
386
382
|
lambda { @uri.write @content }.should raise_error(RuntimeError, /failed to upload/i)
|
387
383
|
end
|
388
384
|
|
@@ -397,7 +393,7 @@ describe URI::SFTP, '#read' do
|
|
397
393
|
@ssh_session = mock('Net::SSH::Session')
|
398
394
|
@sftp_session = mock('Net::SFTP::Session')
|
399
395
|
@file_factory = mock('Net::SFTP::Operations::FileFactory')
|
400
|
-
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22) do
|
396
|
+
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22).and_return(@ssh_session) do
|
401
397
|
Net::SFTP::Session.should_receive(:new).with(@ssh_session).and_yield(@sftp_session).and_return(@sftp_session)
|
402
398
|
@sftp_session.should_receive(:connect!).and_return(@sftp_session)
|
403
399
|
@sftp_session.should_receive(:loop)
|
@@ -445,7 +441,7 @@ describe URI::SFTP, '#write' do
|
|
445
441
|
@ssh_session = mock('Net::SSH::Session')
|
446
442
|
@sftp_session = mock('Net::SFTP::Session')
|
447
443
|
@file_factory = mock('Net::SFTP::Operations::FileFactory')
|
448
|
-
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22) do
|
444
|
+
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22).and_return(@ssh_session) do
|
449
445
|
Net::SFTP::Session.should_receive(:new).with(@ssh_session).and_yield(@sftp_session).and_return(@sftp_session)
|
450
446
|
@sftp_session.should_receive(:connect!).and_return(@sftp_session)
|
451
447
|
@sftp_session.should_receive(:loop)
|
@@ -0,0 +1,80 @@
|
|
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
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
|
+
|
18
|
+
|
19
|
+
describe Buildr::Groovy::EasyB do
|
20
|
+
|
21
|
+
def foo(*args, &prc)
|
22
|
+
define('foo', *args) do
|
23
|
+
test.using :easyb
|
24
|
+
if prc
|
25
|
+
instance_eval(&prc)
|
26
|
+
else
|
27
|
+
self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should apply to a project having EasyB sources' do
|
33
|
+
define('one', :base_dir => 'one') do
|
34
|
+
write _('src/spec/groovy/SomeBehaviour.groovy'), 'true;'
|
35
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_true
|
36
|
+
end
|
37
|
+
define('two', :base_dir => 'two') do
|
38
|
+
write _('src/test/groovy/SomeBehaviour.groovy'), 'true;'
|
39
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_false
|
40
|
+
end
|
41
|
+
define('three', :base_dir => 'three') do
|
42
|
+
write _('src/spec/groovy/SomeStory.groovy'), 'true;'
|
43
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_true
|
44
|
+
end
|
45
|
+
define('four', :base_dir => 'four') do
|
46
|
+
write _('src/test/groovy/SomeStory.groovy'), 'true;'
|
47
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should be selected by :easyb name' do
|
52
|
+
foo { test.framework.should eql(:easyb) }
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should select a java compiler if java sources are found' do
|
56
|
+
foo do
|
57
|
+
write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
|
58
|
+
test.compile.language.should eql(:java)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should include src/spec/groovy/*Behavior.groovy' do
|
63
|
+
foo do
|
64
|
+
spec = _('src/spec/groovy/SomeBehavior.groovy')
|
65
|
+
write spec, 'true'
|
66
|
+
test.invoke
|
67
|
+
test.tests.should include(spec)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should include src/spec/groovy/*Story.groovy' do
|
72
|
+
foo do
|
73
|
+
spec = _('src/spec/groovy/SomeStory.groovy')
|
74
|
+
write spec, 'true'
|
75
|
+
test.invoke
|
76
|
+
test.tests.should include(spec)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end # EasyB
|
@@ -0,0 +1,243 @@
|
|
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.join(File.dirname(__FILE__), '../spec_helpers')
|
18
|
+
|
19
|
+
|
20
|
+
module EclipseHelper
|
21
|
+
def classpath_xml_elements
|
22
|
+
task('eclipse').invoke
|
23
|
+
REXML::Document.new(File.open('.classpath')).root.elements
|
24
|
+
end
|
25
|
+
|
26
|
+
def classpath_sources attribute='path'
|
27
|
+
classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes[attribute] }
|
28
|
+
end
|
29
|
+
|
30
|
+
# <classpathentry path="PATH" output="RETURNED_VALUE"/>
|
31
|
+
def classpath_specific_output path
|
32
|
+
specific_output = classpath_xml_elements.collect("classpathentry[@path='#{path}']") { |n| n.attributes['output'] }
|
33
|
+
raise "expected: one output attribute for path '#{path}, got: #{specific_output.inspect}" if specific_output.length > 1
|
34
|
+
specific_output[0]
|
35
|
+
end
|
36
|
+
|
37
|
+
# <classpathentry path="RETURNED_VALUE" kind="output"/>
|
38
|
+
def classpath_default_output
|
39
|
+
default_output = classpath_xml_elements.collect("classpathentry[@kind='output']") { |n| n.attributes['path'] }
|
40
|
+
raise "expected: one path attribute for kind='output', got: #{default_output.inspect}" if default_output.length > 1
|
41
|
+
default_output[0]
|
42
|
+
end
|
43
|
+
|
44
|
+
def project_xml_elements
|
45
|
+
task('eclipse').invoke
|
46
|
+
REXML::Document.new(File.open('.project')).root.elements
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe Buildr::Eclipse do
|
52
|
+
include EclipseHelper
|
53
|
+
|
54
|
+
describe "eclipse's .project file" do
|
55
|
+
|
56
|
+
describe 'scala project' do
|
57
|
+
|
58
|
+
SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
|
59
|
+
JAVA_NATURE = 'org.eclipse.jdt.core.javanature'
|
60
|
+
|
61
|
+
SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
|
62
|
+
JAVA_BUILDER = 'org.eclipse.jdt.core.javabuilder'
|
63
|
+
|
64
|
+
def project_natures
|
65
|
+
project_xml_elements.collect("natures/nature") { |n| n.text }
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_commands
|
69
|
+
project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
|
70
|
+
end
|
71
|
+
|
72
|
+
before do
|
73
|
+
write 'buildfile'
|
74
|
+
write 'src/main/scala/Main.scala'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should have Scala nature before Java nature' do
|
78
|
+
define('foo')
|
79
|
+
project_natures.should include(SCALA_NATURE)
|
80
|
+
project_natures.should include(JAVA_NATURE)
|
81
|
+
project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should have Scala build command and no Java build command' do
|
85
|
+
define('foo')
|
86
|
+
build_commands.should include(SCALA_BUILDER)
|
87
|
+
build_commands.should_not include(JAVA_BUILDER)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "eclipse's .classpath file" do
|
93
|
+
|
94
|
+
describe 'scala project' do
|
95
|
+
|
96
|
+
SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
|
97
|
+
JAVA_CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
|
98
|
+
|
99
|
+
def classpath_containers attribute='path'
|
100
|
+
classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
|
101
|
+
end
|
102
|
+
|
103
|
+
before do
|
104
|
+
write 'buildfile'
|
105
|
+
write 'src/main/scala/Main.scala'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should have SCALA_CONTAINER before JRE_CONTAINER' do
|
109
|
+
define('foo')
|
110
|
+
classpath_containers.should include(SCALA_CONTAINER)
|
111
|
+
classpath_containers.should include(JAVA_CONTAINER)
|
112
|
+
classpath_containers.index(SCALA_CONTAINER).should < classpath_containers.index(JAVA_CONTAINER)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe 'source folders' do
|
117
|
+
|
118
|
+
before do
|
119
|
+
write 'buildfile'
|
120
|
+
write 'src/main/java/Main.java'
|
121
|
+
write 'src/test/java/Test.java'
|
122
|
+
end
|
123
|
+
|
124
|
+
describe 'source', :shared=>true do
|
125
|
+
it 'should ignore CVS and SVN files' do
|
126
|
+
define('foo')
|
127
|
+
classpath_sources('excluding').each do |excluding_attribute|
|
128
|
+
excluding = excluding_attribute.split('|')
|
129
|
+
excluding.should include('**/.svn/')
|
130
|
+
excluding.should include('**/CVS/')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'main code' do
|
136
|
+
it_should_behave_like 'source'
|
137
|
+
|
138
|
+
it 'should accept to come from the default directory' do
|
139
|
+
define('foo')
|
140
|
+
classpath_sources.should include('src/main/java')
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should accept to come from a user-defined directory' do
|
144
|
+
define('foo') { compile path_to('src/java') }
|
145
|
+
classpath_sources.should include('src/java')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should accept a file task as a main source folder' do
|
149
|
+
define('foo') { compile apt }
|
150
|
+
classpath_sources.should include('target/generated/apt')
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should go to the default target directory' do
|
154
|
+
define('foo')
|
155
|
+
classpath_specific_output('src/main/java').should be(nil)
|
156
|
+
classpath_default_output.should == 'target/classes'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'test code' do
|
161
|
+
it_should_behave_like 'source'
|
162
|
+
|
163
|
+
it 'should accept to come from the default directory' do
|
164
|
+
define('foo')
|
165
|
+
classpath_sources.should include('src/test/java')
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should accept to come from a user-defined directory' do
|
169
|
+
define('foo') { test.compile path_to('src/test') }
|
170
|
+
classpath_sources.should include('src/test')
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should go to the default target directory' do
|
174
|
+
define('foo')
|
175
|
+
classpath_specific_output('src/test/java').should == 'target/test/classes'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe 'main resources' do
|
180
|
+
it_should_behave_like 'source'
|
181
|
+
|
182
|
+
before do
|
183
|
+
write 'src/main/resources/config.xml'
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should accept to come from the default directory' do
|
187
|
+
define('foo')
|
188
|
+
classpath_sources.should include('src/main/resources')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should share a classpath entry if it comes from a directory with code' do
|
192
|
+
write 'src/main/java/config.properties'
|
193
|
+
define('foo') { resources.from('src/main/java').exclude('**/*.java') }
|
194
|
+
classpath_sources.select { |path| path == 'src/main/java'}.length.should == 1
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should go to the default target directory' do
|
198
|
+
define('foo')
|
199
|
+
classpath_specific_output('src/main/resources').should == 'target/resources'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'test resources' do
|
204
|
+
it_should_behave_like 'source'
|
205
|
+
|
206
|
+
before do
|
207
|
+
write 'src/test/resources/config-test.xml'
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should accept to come from the default directory' do
|
211
|
+
define('foo')
|
212
|
+
classpath_sources.should include('src/test/resources')
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should share a classpath entry if it comes from a directory with code' do
|
216
|
+
write 'src/test/java/config-test.properties'
|
217
|
+
define('foo') { test.resources.from('src/test/java').exclude('**/*.java') }
|
218
|
+
classpath_sources.select { |path| path == 'src/test/java'}.length.should == 1
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should go to the default target directory' do
|
222
|
+
define('foo')
|
223
|
+
classpath_specific_output('src/test/resources').should == 'target/test/resources'
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe 'project depending on another project' do
|
228
|
+
|
229
|
+
it 'should have the underlying project in its classpath' do
|
230
|
+
mkdir 'bar'
|
231
|
+
define('myproject') {
|
232
|
+
project.version = '1.0'
|
233
|
+
define('foo') { package :jar }
|
234
|
+
define('bar') { compile.using(:javac).with project('foo'); }
|
235
|
+
}
|
236
|
+
task('eclipse').invoke
|
237
|
+
REXML::Document.new(File.open(File.join('bar', '.classpath'))).root.
|
238
|
+
elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/myproject-foo')
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -13,26 +13,16 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
17
16
|
|
18
|
-
|
19
|
-
before do
|
20
|
-
@old_home, ENV['JAVA_HOME'] = ENV['JAVA_HOME'], nil
|
21
|
-
Config::CONFIG.should_receive(:[]).with('host_os').and_return('darwin0.9')
|
22
|
-
end
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
23
18
|
|
24
|
-
it 'should point to default JVM' do
|
25
|
-
load File.expand_path('../lib/buildr/java.rb')
|
26
|
-
ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.framework/Home'
|
27
|
-
end
|
28
19
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
describe Buildr::Ant do
|
21
|
+
|
22
|
+
it 'should pick Ant version from ant build settings' do
|
23
|
+
Buildr::Ant.instance_eval { @dependencies = nil }
|
24
|
+
write 'build.yaml', 'ant: 1.2.3'
|
25
|
+
Buildr::Ant.dependencies.should include("org.apache.ant:ant:jar:1.2.3")
|
33
26
|
end
|
34
27
|
|
35
|
-
after do
|
36
|
-
ENV['JAVA_HOME'] = @old_home
|
37
|
-
end
|
38
28
|
end
|
@@ -0,0 +1,358 @@
|
|
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
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
|
+
|
18
|
+
describe Buildr::RSpec do
|
19
|
+
|
20
|
+
def foo(*args, &prc)
|
21
|
+
define('foo', *args) do
|
22
|
+
test.using :rspec, :output => false
|
23
|
+
if prc
|
24
|
+
instance_eval(&prc)
|
25
|
+
else
|
26
|
+
self
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be selected by :rspec name' do
|
32
|
+
foo { test.framework.should eql(:rspec) }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should run rspecs' do
|
36
|
+
success = File.expand_path('src/spec/ruby/success_spec.rb')
|
37
|
+
write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
|
38
|
+
failure = File.expand_path('src/spec/ruby/failure_spec.rb')
|
39
|
+
write(failure, 'describe("failure") { it("is false") { true.should == false } }')
|
40
|
+
error = File.expand_path('src/spec/ruby/error_spec.rb')
|
41
|
+
write(error, 'describe("error") { it("raises") { lambda; } }')
|
42
|
+
foo do
|
43
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
44
|
+
test.tests.should include(success, failure, error)
|
45
|
+
test.failed_tests.should include(failure, error)
|
46
|
+
test.passed_tests.should include(success)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # RSpec
|
51
|
+
|
52
|
+
describe Buildr::JtestR do
|
53
|
+
|
54
|
+
def foo(*args, &prc)
|
55
|
+
define('foo', *args) do
|
56
|
+
test.using :jtestr, :output => false
|
57
|
+
if prc
|
58
|
+
instance_eval(&prc)
|
59
|
+
else
|
60
|
+
self
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should be selected by :jtestr name' do
|
66
|
+
foo { test.framework.should eql(:jtestr) }
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should apply to projects having test_unit sources' do
|
70
|
+
define('one', :base_dir => 'one') do
|
71
|
+
write _('src/spec/ruby/one_test.rb')
|
72
|
+
JtestR.applies_to?(self).should be_true
|
73
|
+
end
|
74
|
+
define('two', :base_dir => 'two') do
|
75
|
+
write _('src/spec/ruby/twoTest.rb')
|
76
|
+
JtestR.applies_to?(self).should be_true
|
77
|
+
end
|
78
|
+
define('three', :base_dir => 'three') do
|
79
|
+
write _('src/spec/ruby/tc_three.rb')
|
80
|
+
JtestR.applies_to?(self).should be_true
|
81
|
+
end
|
82
|
+
define('four', :base_dir => 'four') do
|
83
|
+
write _('src/spec/ruby/ts_four.rb')
|
84
|
+
JtestR.applies_to?(self).should be_true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should apply to projects having rspec sources' do
|
89
|
+
define('one', :base_dir => 'one') do
|
90
|
+
write _('src/spec/ruby/one_spec.rb')
|
91
|
+
JtestR.applies_to?(self).should be_true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should apply to projects having expectations sources' do
|
96
|
+
define('one', :base_dir => 'one') do
|
97
|
+
write _('src/spec/ruby/one_expect.rb')
|
98
|
+
JtestR.applies_to?(self).should be_true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should apply to projects having junit sources' do
|
103
|
+
define('one', :base_dir => 'one') do
|
104
|
+
write _('src/test/java/example/OneTest.java', <<-JAVA)
|
105
|
+
package example;
|
106
|
+
public class OneTest extends junit.framework.TestCase { }
|
107
|
+
JAVA
|
108
|
+
JtestR.applies_to?(self).should be_true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should apply to projects having testng sources' do
|
113
|
+
define('one', :base_dir => 'one') do
|
114
|
+
write _('src/test/java/example/OneTest.java', <<-JAVA)
|
115
|
+
package example;
|
116
|
+
public class OneTest {
|
117
|
+
@org.testng.annotations.Test
|
118
|
+
public void testNothing() {}
|
119
|
+
}
|
120
|
+
JAVA
|
121
|
+
JtestR.applies_to?(self).should be_true
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should use a java compiler if java sources found' do
|
126
|
+
foo do
|
127
|
+
write _('src/spec/java/Something.java'), 'public class Something {}'
|
128
|
+
test.compile.language.should eql(:java)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should load user jtestr_config.rb' do
|
133
|
+
foo do
|
134
|
+
hello = _('hello')
|
135
|
+
write('src/spec/ruby/jtestr_config.rb', "File.open('#{hello}', 'w') { |f| f.write 'HELLO' }")
|
136
|
+
write('src/spec/ruby/some_spec.rb')
|
137
|
+
test.invoke
|
138
|
+
File.should be_exist(hello)
|
139
|
+
File.read(hello).should == 'HELLO'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should run junit tests' do
|
144
|
+
write('src/test/java/example/SuccessTest.java', <<-JAVA)
|
145
|
+
package example;
|
146
|
+
public class SuccessTest extends junit.framework.TestCase {
|
147
|
+
public void testSuccess() { assertTrue(true); }
|
148
|
+
}
|
149
|
+
JAVA
|
150
|
+
write('src/test/java/example/FailureTest.java', <<-JAVA)
|
151
|
+
package example;
|
152
|
+
public class FailureTest extends junit.framework.TestCase {
|
153
|
+
public void testFailure() { assertTrue(false); }
|
154
|
+
}
|
155
|
+
JAVA
|
156
|
+
foo do
|
157
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
158
|
+
test.tests.should include('example.SuccessTest', 'example.FailureTest')
|
159
|
+
test.failed_tests.should include('example.FailureTest')
|
160
|
+
test.passed_tests.should include('example.SuccessTest')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should run testng tests' do
|
165
|
+
write('src/test/java/example/Success.java', <<-JAVA)
|
166
|
+
package example;
|
167
|
+
public class Success {
|
168
|
+
@org.testng.annotations.Test
|
169
|
+
public void annotatedSuccess() { org.testng.Assert.assertTrue(true); }
|
170
|
+
}
|
171
|
+
JAVA
|
172
|
+
write('src/test/java/example/Failure.java', <<-JAVA)
|
173
|
+
package example;
|
174
|
+
public class Failure {
|
175
|
+
@org.testng.annotations.Test
|
176
|
+
public void annotatedFail() { org.testng.Assert.fail("FAIL"); }
|
177
|
+
}
|
178
|
+
JAVA
|
179
|
+
foo do
|
180
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
181
|
+
test.tests.should include('example.Success', 'example.Failure')
|
182
|
+
test.failed_tests.should include('example.Failure')
|
183
|
+
test.passed_tests.should include('example.Success')
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should run test_unit' do
|
188
|
+
success = File.expand_path('src/spec/ruby/success_test.rb')
|
189
|
+
write(success, <<-TESTUNIT)
|
190
|
+
require 'test/unit'
|
191
|
+
class TC_Success < Test::Unit::TestCase
|
192
|
+
def test_success
|
193
|
+
assert true
|
194
|
+
end
|
195
|
+
end
|
196
|
+
TESTUNIT
|
197
|
+
failure = File.expand_path('src/spec/ruby/failure_test.rb')
|
198
|
+
write(failure, <<-TESTUNIT)
|
199
|
+
require 'test/unit'
|
200
|
+
class TC_Failure < Test::Unit::TestCase
|
201
|
+
def test_failure
|
202
|
+
assert false
|
203
|
+
end
|
204
|
+
end
|
205
|
+
TESTUNIT
|
206
|
+
error = File.expand_path('src/spec/ruby/error_test.rb')
|
207
|
+
write(error, <<-TESTUNIT)
|
208
|
+
require 'test/unit'
|
209
|
+
class TC_Error < Test::Unit::TestCase
|
210
|
+
def test_error
|
211
|
+
lambda;
|
212
|
+
end
|
213
|
+
end
|
214
|
+
TESTUNIT
|
215
|
+
foo do
|
216
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
217
|
+
test.tests.should include(success, failure, error)
|
218
|
+
test.failed_tests.should include(failure, error)
|
219
|
+
test.passed_tests.should include(success)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should run expectations' do
|
224
|
+
success = File.expand_path('src/spec/ruby/success_expect.rb')
|
225
|
+
write(success, 'Expectations { expect(true) { true } }')
|
226
|
+
failure = File.expand_path('src/spec/ruby/failure_expect.rb')
|
227
|
+
write(failure, 'Expectations { expect(true) { false } }')
|
228
|
+
error = File.expand_path('src/spec/ruby/error_expect.rb')
|
229
|
+
write(error, 'Expectations { expect(nil) { lambda; } }')
|
230
|
+
foo do
|
231
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
232
|
+
test.tests.should include(success, failure, error)
|
233
|
+
test.failed_tests.should include(failure, error)
|
234
|
+
test.passed_tests.should include(success)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should run rspecs' do
|
239
|
+
success = File.expand_path('src/spec/ruby/success_spec.rb')
|
240
|
+
write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
|
241
|
+
failure = File.expand_path('src/spec/ruby/failure_spec.rb')
|
242
|
+
write(failure, 'describe("failure") { it("is false") { true.should == false } }')
|
243
|
+
error = File.expand_path('src/spec/ruby/error_spec.rb')
|
244
|
+
write(error, 'describe("error") { it("raises") { lambda; } }')
|
245
|
+
pending = File.expand_path('src/spec/ruby/pending_spec.rb')
|
246
|
+
write(pending, 'describe("peding") { it "is not implemented" }')
|
247
|
+
foo do
|
248
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
249
|
+
test.tests.should include(success, failure, error)
|
250
|
+
test.failed_tests.should include(failure, error)
|
251
|
+
test.passed_tests.should include(success)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # JtestR
|
257
|
+
|
258
|
+
describe Buildr::JBehave do
|
259
|
+
def foo(*args, &prc)
|
260
|
+
define('foo', *args) do
|
261
|
+
test.using :jbehave
|
262
|
+
if prc
|
263
|
+
instance_eval(&prc)
|
264
|
+
else
|
265
|
+
self
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'should apply to projects having JBehave sources' do
|
271
|
+
define('one', :base_dir => 'one') do
|
272
|
+
write _('src/spec/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
|
273
|
+
JBehave.applies_to?(self).should be_true
|
274
|
+
end
|
275
|
+
define('two', :base_dir => 'two') do
|
276
|
+
write _('src/test/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
|
277
|
+
JBehave.applies_to?(self).should be_false
|
278
|
+
end
|
279
|
+
define('three', :base_dir => 'three') do
|
280
|
+
write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
|
281
|
+
JBehave.applies_to?(self).should be_true
|
282
|
+
end
|
283
|
+
define('four', :base_dir => 'four') do
|
284
|
+
write _('src/test/java/SomeBehavior.java'), 'public class SomeBehavior {}'
|
285
|
+
JBehave.applies_to?(self).should be_false
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
it 'should be selected by :jbehave name' do
|
290
|
+
foo { test.framework.should eql(:jbehave) }
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'should select a java compiler for its sources' do
|
294
|
+
write 'src/test/java/SomeBehavior.java', 'public class SomeBehavior {}'
|
295
|
+
foo do
|
296
|
+
test.compile.language.should eql(:java)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'should include JBehave dependencies' do
|
301
|
+
foo do
|
302
|
+
test.compile.dependencies.should include(artifact("org.jbehave:jbehave:jar::#{JBehave.version}"))
|
303
|
+
test.dependencies.should include(artifact("org.jbehave:jbehave:jar::#{JBehave.version}"))
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'should include JMock dependencies' do
|
308
|
+
foo do
|
309
|
+
test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
310
|
+
test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'should include classes whose name ends with Behavior' do
|
315
|
+
write 'src/spec/java/some/FooBehavior.java', <<-JAVA
|
316
|
+
package some;
|
317
|
+
public class FooBehavior {
|
318
|
+
public void shouldFoo() { assert true; }
|
319
|
+
}
|
320
|
+
JAVA
|
321
|
+
write 'src/spec/java/some/NotATest.java', <<-JAVA
|
322
|
+
package some;
|
323
|
+
public class NotATest { }
|
324
|
+
JAVA
|
325
|
+
foo.tap do |project|
|
326
|
+
project.test.invoke
|
327
|
+
project.test.tests.should include('some.FooBehavior')
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
|
332
|
+
it 'should include classes implementing Behaviours' do
|
333
|
+
write 'src/spec/java/some/MyBehaviours.java', <<-JAVA
|
334
|
+
package some;
|
335
|
+
public class MyBehaviours implements
|
336
|
+
org.jbehave.core.behaviour.Behaviours {
|
337
|
+
public Class[] getBehaviours() {
|
338
|
+
return new Class[] { some.FooBehave.class };
|
339
|
+
}
|
340
|
+
}
|
341
|
+
JAVA
|
342
|
+
write 'src/spec/java/some/FooBehave.java', <<-JAVA
|
343
|
+
package some;
|
344
|
+
public class FooBehave {
|
345
|
+
public void shouldFoo() { assert true; }
|
346
|
+
}
|
347
|
+
JAVA
|
348
|
+
write 'src/spec/java/some/NotATest.java', <<-JAVA
|
349
|
+
package some;
|
350
|
+
public class NotATest { }
|
351
|
+
JAVA
|
352
|
+
foo.tap do |project|
|
353
|
+
project.test.invoke
|
354
|
+
project.test.tests.should include('some.MyBehaviours')
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
end # JBehave
|