mguymon-buildr 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1291 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +44 -0
- data/_buildr +35 -0
- data/_jbuildr +35 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/bnd.rb +147 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +149 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jaxb_xjc.rb +72 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +88 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/protobuf.rb +88 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +78 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +90 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +217 -0
- data/doc/building.textile +276 -0
- data/doc/contributing.textile +268 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +151 -0
- data/doc/extending.textile +212 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +109 -0
- data/doc/installing.textile +284 -0
- data/doc/languages.textile +599 -0
- data/doc/mailing_lists.textile +29 -0
- data/doc/more_stuff.textile +845 -0
- data/doc/packaging.textile +618 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +276 -0
- data/doc/quick_start.textile +210 -0
- data/doc/releasing.textile +117 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +73 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +287 -0
- data/doc/testing.textile +247 -0
- data/etc/KEYS +189 -0
- data/lib/buildr.rb +44 -0
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +34 -0
- data/lib/buildr/core/application.rb +700 -0
- data/lib/buildr/core/build.rb +516 -0
- data/lib/buildr/core/cc.rb +166 -0
- data/lib/buildr/core/checks.rb +253 -0
- data/lib/buildr/core/common.rb +151 -0
- data/lib/buildr/core/compile.rb +622 -0
- data/lib/buildr/core/doc.rb +276 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +404 -0
- data/lib/buildr/core/generate.rb +197 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +975 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/shell.rb +137 -0
- data/lib/buildr/core/test.rb +843 -0
- data/lib/buildr/core/transports.rb +575 -0
- data/lib/buildr/core/util.rb +537 -0
- data/lib/buildr/groovy.rb +20 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +153 -0
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +57 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +427 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/lib/buildr/ide/idea.rb +576 -0
- data/lib/buildr/java.rb +25 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +460 -0
- data/lib/buildr/java/cobertura.rb +297 -0
- data/lib/buildr/java/commands.rb +223 -0
- data/lib/buildr/java/compiler.rb +135 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/doc.rb +86 -0
- data/lib/buildr/java/ecj.rb +69 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/external.rb +73 -0
- data/lib/buildr/java/jruby.rb +122 -0
- data/lib/buildr/java/jtestr_result.rb +295 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
- data/lib/buildr/java/packaging.rb +734 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +154 -0
- data/lib/buildr/java/test_result.rb +101 -0
- data/lib/buildr/java/tests.rb +362 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +25 -0
- data/lib/buildr/packaging/archive.rb +535 -0
- data/lib/buildr/packaging/artifact.rb +904 -0
- data/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +105 -0
- data/lib/buildr/packaging/package.rb +249 -0
- data/lib/buildr/packaging/repository_array.rb +108 -0
- data/lib/buildr/packaging/tar.rb +189 -0
- data/lib/buildr/packaging/version_requirement.rb +192 -0
- data/lib/buildr/packaging/zip.rb +178 -0
- data/lib/buildr/packaging/ziptask.rb +356 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/resources/completed.png +0 -0
- data/lib/buildr/resources/failed.png +0 -0
- data/lib/buildr/resources/icons-license.txt +17 -0
- data/lib/buildr/run.rb +195 -0
- data/lib/buildr/scala.rb +26 -0
- data/lib/buildr/scala/bdd.rb +118 -0
- data/lib/buildr/scala/compiler.rb +242 -0
- data/lib/buildr/scala/doc.rb +142 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +52 -0
- data/lib/buildr/scala/tests.rb +171 -0
- data/lib/buildr/shell.rb +185 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +137 -0
- data/rakelib/metrics.rake +39 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +160 -0
- data/rakelib/rspec.rake +91 -0
- data/rakelib/setup.rake +66 -0
- data/rakelib/stage.rake +220 -0
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +631 -0
- data/spec/core/build_spec.rb +837 -0
- data/spec/core/cc_spec.rb +224 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +725 -0
- data/spec/core/compile_spec.rb +658 -0
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/extension_spec.rb +201 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +772 -0
- data/spec/core/run_spec.rb +93 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/core/test_spec.rb +1320 -0
- data/spec/core/transport_spec.rb +544 -0
- data/spec/core/util_spec.rb +141 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +251 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +739 -0
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/ant_spec.rb +37 -0
- data/spec/java/bdd_spec.rb +374 -0
- data/spec/java/cobertura_spec.rb +112 -0
- data/spec/java/commands_spec.rb +93 -0
- data/spec/java/compiler_spec.rb +252 -0
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/ecj_spec.rb +115 -0
- data/spec/java/emma_spec.rb +121 -0
- data/spec/java/external_spec.rb +56 -0
- data/spec/java/java_spec.rb +132 -0
- data/spec/java/packaging_spec.rb +1266 -0
- data/spec/java/run_spec.rb +78 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +497 -0
- data/spec/packaging/archive_spec.rb +775 -0
- data/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/spec/packaging/artifact_spec.rb +1074 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +719 -0
- data/spec/packaging/repository_array_spec.rb +109 -0
- data/spec/sandbox.rb +165 -0
- data/spec/scala/bdd_spec.rb +124 -0
- data/spec/scala/compiler_spec.rb +289 -0
- data/spec/scala/doc_spec.rb +88 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +283 -0
- data/spec/spec_helpers.rb +369 -0
- data/spec/version_requirement_spec.rb +143 -0
- data/spec/xpath_matchers.rb +121 -0
- metadata +649 -0
@@ -0,0 +1,37 @@
|
|
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 Buildr::Ant do
|
21
|
+
|
22
|
+
it 'should pick Ant version from ant build settings' do
|
23
|
+
begin
|
24
|
+
Buildr::Ant.instance_eval { @dependencies = nil }
|
25
|
+
write 'build.yaml', 'ant: 1.2.3'
|
26
|
+
Buildr::Ant.dependencies.should include("org.apache.ant:ant:jar:1.2.3")
|
27
|
+
ensure
|
28
|
+
Buildr::Ant.instance_eval { @dependencies = nil }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have REQUIRES up to version 1.5 since it was deprecated in version 1.3.3' do
|
33
|
+
Buildr::VERSION.should < '1.5'
|
34
|
+
lambda { Ant::REQUIRES }.should_not raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,374 @@
|
|
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.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
|
17
|
+
|
18
|
+
describe Buildr::RSpec do
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
define('foo') do
|
22
|
+
test.using :rspec, :output => false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should be selected by :rspec name' do
|
27
|
+
project('foo').test.framework.should eql(:rspec)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should read passed specs from result yaml' do
|
31
|
+
write('src/spec/ruby/success_spec.rb', 'describe("success") { it("is true") { nil.should be_nil } }')
|
32
|
+
|
33
|
+
project('foo').test.invoke
|
34
|
+
project('foo').test.passed_tests.should eql([File.expand_path('src/spec/ruby/success_spec.rb')])
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should read result yaml to obtain the list of failed specs' do
|
38
|
+
success = File.expand_path('src/spec/ruby/success_spec.rb')
|
39
|
+
write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
|
40
|
+
failure = File.expand_path('src/spec/ruby/failure_spec.rb')
|
41
|
+
write(failure, 'describe("failure") { it("is false") { true.should == false } }')
|
42
|
+
error = File.expand_path('src/spec/ruby/error_spec.rb')
|
43
|
+
write(error, 'describe("error") { it("raises") { lambda; } }')
|
44
|
+
|
45
|
+
lambda { project('foo').test.invoke }.should raise_error(/Tests failed/)
|
46
|
+
project('foo').test.tests.should include(success, failure, error)
|
47
|
+
project('foo').test.failed_tests.sort.should eql([failure, error].sort)
|
48
|
+
project('foo').test.passed_tests.should eql([success])
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # RSpec
|
53
|
+
|
54
|
+
describe Buildr::JtestR do
|
55
|
+
|
56
|
+
before do
|
57
|
+
# clear cached dependencies
|
58
|
+
Buildr::JUnit.instance_eval { @dependencies = nil }
|
59
|
+
Buildr::JtestR.instance_eval { @dependencies = nil }
|
60
|
+
end
|
61
|
+
|
62
|
+
def foo(*args, &prc)
|
63
|
+
define('foo', *args) do
|
64
|
+
test.using :jtestr, :output => false
|
65
|
+
if prc
|
66
|
+
instance_eval(&prc)
|
67
|
+
else
|
68
|
+
self
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should be selected by :jtestr name' do
|
74
|
+
foo { test.framework.should eql(:jtestr) }
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should apply to projects having test_unit sources' do
|
78
|
+
define('one', :base_dir => 'one') do
|
79
|
+
write _('src/spec/ruby/one_test.rb')
|
80
|
+
JtestR.applies_to?(self).should be_true
|
81
|
+
end
|
82
|
+
define('two', :base_dir => 'two') do
|
83
|
+
write _('src/spec/ruby/twoTest.rb')
|
84
|
+
JtestR.applies_to?(self).should be_true
|
85
|
+
end
|
86
|
+
define('three', :base_dir => 'three') do
|
87
|
+
write _('src/spec/ruby/tc_three.rb')
|
88
|
+
JtestR.applies_to?(self).should be_true
|
89
|
+
end
|
90
|
+
define('four', :base_dir => 'four') do
|
91
|
+
write _('src/spec/ruby/ts_four.rb')
|
92
|
+
JtestR.applies_to?(self).should be_true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should apply to projects having rspec sources' do
|
97
|
+
define('one', :base_dir => 'one') do
|
98
|
+
write _('src/spec/ruby/one_spec.rb')
|
99
|
+
JtestR.applies_to?(self).should be_true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should apply to projects having expectations sources' do
|
104
|
+
define('one', :base_dir => 'one') do
|
105
|
+
write _('src/spec/ruby/one_expect.rb')
|
106
|
+
JtestR.applies_to?(self).should be_true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should apply to projects having junit sources' do
|
111
|
+
define('one', :base_dir => 'one') do
|
112
|
+
write _('src/test/java/example/OneTest.java'), <<-JAVA
|
113
|
+
package example;
|
114
|
+
public class OneTest extends junit.framework.TestCase { }
|
115
|
+
JAVA
|
116
|
+
JtestR.applies_to?(self).should be_true
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should apply to projects having testng sources' do
|
121
|
+
define('one', :base_dir => 'one') do
|
122
|
+
write _('src/test/java/example/OneTest.java'), <<-JAVA
|
123
|
+
package example;
|
124
|
+
public class OneTest {
|
125
|
+
@org.testng.annotations.Test
|
126
|
+
public void testNothing() {}
|
127
|
+
}
|
128
|
+
JAVA
|
129
|
+
JtestR.applies_to?(self).should be_true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should use a java compiler if java sources found' do
|
134
|
+
foo do
|
135
|
+
write _('src/spec/java/Something.java'), 'public class Something {}'
|
136
|
+
test.compile.language.should eql(:java)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should load user jtestr_config.rb' do
|
141
|
+
foo do
|
142
|
+
hello = _('hello')
|
143
|
+
write('src/spec/ruby/jtestr_config.rb', "File.open('#{hello}', 'w') { |f| f.write 'HELLO' }")
|
144
|
+
write('src/spec/ruby/some_spec.rb')
|
145
|
+
test.invoke
|
146
|
+
File.should be_exist(hello)
|
147
|
+
File.read(hello).should == 'HELLO'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should run junit tests' do
|
152
|
+
write('src/test/java/example/SuccessTest.java', <<-JAVA)
|
153
|
+
package example;
|
154
|
+
public class SuccessTest extends junit.framework.TestCase {
|
155
|
+
public void testSuccess() { assertTrue(true); }
|
156
|
+
}
|
157
|
+
JAVA
|
158
|
+
write('src/test/java/example/FailureTest.java', <<-JAVA)
|
159
|
+
package example;
|
160
|
+
public class FailureTest extends junit.framework.TestCase {
|
161
|
+
public void testFailure() { assertTrue(false); }
|
162
|
+
}
|
163
|
+
JAVA
|
164
|
+
foo do
|
165
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
166
|
+
test.tests.should include('example.SuccessTest', 'example.FailureTest')
|
167
|
+
test.failed_tests.should include('example.FailureTest')
|
168
|
+
test.passed_tests.should include('example.SuccessTest')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should run testng tests' do
|
173
|
+
write('src/test/java/example/Success.java', <<-JAVA)
|
174
|
+
package example;
|
175
|
+
public class Success {
|
176
|
+
@org.testng.annotations.Test
|
177
|
+
public void annotatedSuccess() { org.testng.Assert.assertTrue(true); }
|
178
|
+
}
|
179
|
+
JAVA
|
180
|
+
write('src/test/java/example/Failure.java', <<-JAVA)
|
181
|
+
package example;
|
182
|
+
public class Failure {
|
183
|
+
@org.testng.annotations.Test
|
184
|
+
public void annotatedFail() { org.testng.Assert.fail("FAIL"); }
|
185
|
+
}
|
186
|
+
JAVA
|
187
|
+
foo do
|
188
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
189
|
+
test.tests.should include('example.Success', 'example.Failure')
|
190
|
+
test.failed_tests.should include('example.Failure')
|
191
|
+
test.passed_tests.should include('example.Success')
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should run test_unit' do
|
196
|
+
success = File.expand_path('src/spec/ruby/success_test.rb')
|
197
|
+
write(success, <<-TESTUNIT)
|
198
|
+
require 'test/unit'
|
199
|
+
class TC_Success < Test::Unit::TestCase
|
200
|
+
def test_success
|
201
|
+
assert true
|
202
|
+
end
|
203
|
+
end
|
204
|
+
TESTUNIT
|
205
|
+
failure = File.expand_path('src/spec/ruby/failure_test.rb')
|
206
|
+
write(failure, <<-TESTUNIT)
|
207
|
+
require 'test/unit'
|
208
|
+
class TC_Failure < Test::Unit::TestCase
|
209
|
+
def test_failure
|
210
|
+
assert false
|
211
|
+
end
|
212
|
+
end
|
213
|
+
TESTUNIT
|
214
|
+
error = File.expand_path('src/spec/ruby/error_test.rb')
|
215
|
+
write(error, <<-TESTUNIT)
|
216
|
+
require 'test/unit'
|
217
|
+
class TC_Error < Test::Unit::TestCase
|
218
|
+
def test_error
|
219
|
+
lambda;
|
220
|
+
end
|
221
|
+
end
|
222
|
+
TESTUNIT
|
223
|
+
foo do
|
224
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
225
|
+
test.tests.should include(success, failure, error)
|
226
|
+
test.failed_tests.should include(failure, error)
|
227
|
+
test.passed_tests.should include(success)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should run expectations' do
|
232
|
+
success = File.expand_path('src/spec/ruby/success_expect.rb')
|
233
|
+
write(success, 'Expectations { expect(true) { true } }')
|
234
|
+
failure = File.expand_path('src/spec/ruby/failure_expect.rb')
|
235
|
+
write(failure, 'Expectations { expect(true) { false } }')
|
236
|
+
error = File.expand_path('src/spec/ruby/error_expect.rb')
|
237
|
+
write(error, 'Expectations { expect(nil) { lambda {}; } }')
|
238
|
+
foo do
|
239
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
240
|
+
test.tests.should include(success, failure, error)
|
241
|
+
test.failed_tests.should include(failure, error)
|
242
|
+
test.passed_tests.should include(success)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should run rspecs' do
|
247
|
+
success = File.expand_path('src/spec/ruby/success_spec.rb')
|
248
|
+
write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
|
249
|
+
failure = File.expand_path('src/spec/ruby/failure_spec.rb')
|
250
|
+
write(failure, 'describe("failure") { it("is false") { true.should == false } }')
|
251
|
+
error = File.expand_path('src/spec/ruby/error_spec.rb')
|
252
|
+
write(error, 'describe("error") { it("raises") { lambda; } }')
|
253
|
+
pending = File.expand_path('src/spec/ruby/pending_spec.rb')
|
254
|
+
write(pending, 'describe("pending") { it "is not implemented" }')
|
255
|
+
foo do
|
256
|
+
lambda { test.invoke }.should raise_error(/Tests failed/)
|
257
|
+
test.tests.should include(success, failure, error)
|
258
|
+
test.failed_tests.should include(failure, error)
|
259
|
+
test.passed_tests.should include(success)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
after do
|
264
|
+
# reset to default
|
265
|
+
Buildr.settings.build['junit'] = nil
|
266
|
+
Buildr::JUnit.instance_eval { @dependencies = nil }
|
267
|
+
Buildr::JtestR.instance_eval { @dependencies = nil }
|
268
|
+
end
|
269
|
+
|
270
|
+
end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # JtestR
|
271
|
+
|
272
|
+
describe Buildr::JBehave do
|
273
|
+
def foo(*args, &prc)
|
274
|
+
define('foo', *args) do
|
275
|
+
test.using :jbehave
|
276
|
+
if prc
|
277
|
+
instance_eval(&prc)
|
278
|
+
else
|
279
|
+
self
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'should apply to projects having JBehave sources' do
|
285
|
+
define('one', :base_dir => 'one') do
|
286
|
+
write _('src/spec/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
|
287
|
+
JBehave.applies_to?(self).should be_true
|
288
|
+
end
|
289
|
+
define('two', :base_dir => 'two') do
|
290
|
+
write _('src/test/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
|
291
|
+
JBehave.applies_to?(self).should be_false
|
292
|
+
end
|
293
|
+
define('three', :base_dir => 'three') do
|
294
|
+
write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
|
295
|
+
JBehave.applies_to?(self).should be_true
|
296
|
+
end
|
297
|
+
define('four', :base_dir => 'four') do
|
298
|
+
write _('src/test/java/SomeBehavior.java'), 'public class SomeBehavior {}'
|
299
|
+
JBehave.applies_to?(self).should be_false
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'should be selected by :jbehave name' do
|
304
|
+
foo { test.framework.should eql(:jbehave) }
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'should select a java compiler for its sources' do
|
308
|
+
write 'src/test/java/SomeBehavior.java', 'public class SomeBehavior {}'
|
309
|
+
foo do
|
310
|
+
test.compile.language.should eql(:java)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'should include JBehave dependencies' do
|
315
|
+
foo do
|
316
|
+
test.compile.dependencies.should include(artifact("org.jbehave:jbehave:jar::#{JBehave.version}"))
|
317
|
+
test.dependencies.should include(artifact("org.jbehave:jbehave:jar::#{JBehave.version}"))
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'should include JMock dependencies' do
|
322
|
+
foo do
|
323
|
+
two_or_later = JMock.version[0,1].to_i >= 2
|
324
|
+
group = two_or_later ? "org.jmock" : "jmock"
|
325
|
+
test.compile.dependencies.should include(artifact("#{group}:jmock:jar:#{JMock.version}"))
|
326
|
+
test.dependencies.should include(artifact("#{group}:jmock:jar:#{JMock.version}"))
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should include classes whose name ends with Behavior' do
|
331
|
+
write 'src/spec/java/some/FooBehavior.java', <<-JAVA
|
332
|
+
package some;
|
333
|
+
public class FooBehavior {
|
334
|
+
public void shouldFoo() { assert true; }
|
335
|
+
}
|
336
|
+
JAVA
|
337
|
+
write 'src/spec/java/some/NotATest.java', <<-JAVA
|
338
|
+
package some;
|
339
|
+
public class NotATest { }
|
340
|
+
JAVA
|
341
|
+
foo.tap do |project|
|
342
|
+
project.test.invoke
|
343
|
+
project.test.tests.should include('some.FooBehavior')
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
|
348
|
+
it 'should include classes implementing Behaviours' do
|
349
|
+
write 'src/spec/java/some/MyBehaviours.java', <<-JAVA
|
350
|
+
package some;
|
351
|
+
public class MyBehaviours implements
|
352
|
+
org.jbehave.core.behaviour.Behaviours {
|
353
|
+
public Class[] getBehaviours() {
|
354
|
+
return new Class[] { some.FooBehave.class };
|
355
|
+
}
|
356
|
+
}
|
357
|
+
JAVA
|
358
|
+
write 'src/spec/java/some/FooBehave.java', <<-JAVA
|
359
|
+
package some;
|
360
|
+
public class FooBehave {
|
361
|
+
public void shouldFoo() { assert true; }
|
362
|
+
}
|
363
|
+
JAVA
|
364
|
+
write 'src/spec/java/some/NotATest.java', <<-JAVA
|
365
|
+
package some;
|
366
|
+
public class NotATest { }
|
367
|
+
JAVA
|
368
|
+
foo.tap do |project|
|
369
|
+
project.test.invoke
|
370
|
+
project.test.tests.should include('some.MyBehaviours')
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
end # JBehave
|
@@ -0,0 +1,112 @@
|
|
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__), 'test_coverage_helper'))
|
18
|
+
Sandbox.require_optional_extension 'buildr/java/cobertura'
|
19
|
+
artifacts(Buildr::Cobertura::dependencies).map(&:invoke)
|
20
|
+
|
21
|
+
|
22
|
+
describe Buildr::Cobertura do
|
23
|
+
before do
|
24
|
+
# Reloading the extension because the sandbox removes all its actions
|
25
|
+
Buildr.module_eval { remove_const :Cobertura }
|
26
|
+
load File.expand_path('../lib/buildr/java/cobertura.rb')
|
27
|
+
@tool_module = Buildr::Cobertura
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_behave_like 'test coverage tool'
|
31
|
+
|
32
|
+
describe 'project-specific' do
|
33
|
+
|
34
|
+
describe 'data file' do
|
35
|
+
it 'should have a default value' do
|
36
|
+
define('foo').cobertura.data_file.should point_to_path('reports/cobertura.ser')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should be overridable' do
|
40
|
+
define('foo') { cobertura.data_file = path_to('target/data.cobertura') }
|
41
|
+
project('foo').cobertura.data_file.should point_to_path('target/data.cobertura')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should be created during instrumentation' do
|
45
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
46
|
+
define('foo')
|
47
|
+
task('foo:cobertura:instrument').invoke
|
48
|
+
file(project('foo').cobertura.data_file).should exist
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should not instrument projects which have no sources' do
|
52
|
+
write 'bar/src/main/java/Baz.java', 'public class Baz {}'
|
53
|
+
define('foo') { define('bar') }
|
54
|
+
task('foo:bar:cobertura:instrument').invoke
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should not generate html if projects have no sources' do
|
58
|
+
define('foo') { define('bar') }
|
59
|
+
task('cobertura:html').invoke
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'instrumentation' do
|
64
|
+
before do
|
65
|
+
['Foo', 'Bar'].each { |cls| write File.join('src/main/java', "#{cls}.java"), "public class #{cls} {}" }
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should instrument only included classes' do
|
69
|
+
define('foo') { cobertura.include 'Foo' }
|
70
|
+
task("foo:cobertura:instrument").invoke
|
71
|
+
Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Foo.class'] }
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should not instrument excluded classes' do
|
75
|
+
define('foo') { cobertura.exclude 'Foo' }
|
76
|
+
task("foo:cobertura:instrument").invoke
|
77
|
+
Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Bar.class'] }
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should instrument classes that are included but not excluded' do
|
81
|
+
write 'src/main/java/Baz.java', 'public class Baz {}'
|
82
|
+
define('foo') { cobertura.include('Ba').exclude('ar') }
|
83
|
+
task("foo:cobertura:instrument").invoke
|
84
|
+
Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Baz.class'] }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'check' do
|
89
|
+
before do
|
90
|
+
write 'src/main/java/Foo.java', 'public class Foo { public static boolean returnTrue() {return true;}}'
|
91
|
+
write 'src/test/java/FooTest.java', <<-JAVA
|
92
|
+
import static junit.framework.Assert.assertTrue;
|
93
|
+
import org.junit.Test;
|
94
|
+
|
95
|
+
public class FooTest {
|
96
|
+
|
97
|
+
@Test
|
98
|
+
public void testReturnTrue() {
|
99
|
+
assertTrue(Foo.returnTrue());
|
100
|
+
}
|
101
|
+
}
|
102
|
+
JAVA
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should not raise errors during execution' do
|
106
|
+
define('foo') { cobertura.include 'Foo' }
|
107
|
+
lambda {task("foo:cobertura:check").invoke}.should_not raise_error
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|