realityforge-buildr 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.md +3 -0
- data/Rakefile +50 -0
- data/addon/buildr/checkstyle-report.xsl +104 -0
- data/addon/buildr/checkstyle.rb +254 -0
- data/addon/buildr/git_auto_version.rb +36 -0
- data/addon/buildr/gpg.rb +90 -0
- data/addon/buildr/gwt.rb +413 -0
- data/addon/buildr/jacoco.rb +161 -0
- data/addon/buildr/pmd.rb +185 -0
- data/addon/buildr/single_intermediate_layout.rb +71 -0
- data/addon/buildr/spotbugs.rb +265 -0
- data/addon/buildr/top_level_generate_dir.rb +37 -0
- data/addon/buildr/wsgen.rb +192 -0
- data/bin/buildr +20 -0
- data/buildr.gemspec +61 -0
- data/lib/buildr.rb +86 -0
- data/lib/buildr/core/application.rb +705 -0
- data/lib/buildr/core/assets.rb +96 -0
- data/lib/buildr/core/build.rb +587 -0
- data/lib/buildr/core/common.rb +167 -0
- data/lib/buildr/core/compile.rb +599 -0
- data/lib/buildr/core/console.rb +124 -0
- data/lib/buildr/core/doc.rb +275 -0
- data/lib/buildr/core/environment.rb +128 -0
- data/lib/buildr/core/filter.rb +405 -0
- data/lib/buildr/core/help.rb +114 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +994 -0
- data/lib/buildr/core/test.rb +776 -0
- data/lib/buildr/core/transports.rb +456 -0
- data/lib/buildr/core/util.rb +77 -0
- data/lib/buildr/ide/idea.rb +1664 -0
- data/lib/buildr/java/commands.rb +230 -0
- data/lib/buildr/java/compiler.rb +85 -0
- data/lib/buildr/java/custom_pom.rb +300 -0
- data/lib/buildr/java/doc.rb +62 -0
- data/lib/buildr/java/packaging.rb +393 -0
- data/lib/buildr/java/pom.rb +191 -0
- data/lib/buildr/java/test_result.rb +54 -0
- data/lib/buildr/java/tests.rb +111 -0
- data/lib/buildr/packaging/archive.rb +586 -0
- data/lib/buildr/packaging/artifact.rb +1113 -0
- data/lib/buildr/packaging/artifact_namespace.rb +1010 -0
- data/lib/buildr/packaging/artifact_search.rb +138 -0
- data/lib/buildr/packaging/package.rb +237 -0
- data/lib/buildr/packaging/version_requirement.rb +189 -0
- data/lib/buildr/packaging/zip.rb +189 -0
- data/lib/buildr/packaging/ziptask.rb +387 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/release.rake +99 -0
- data/spec/addon/checkstyle_spec.rb +58 -0
- data/spec/core/application_spec.rb +576 -0
- data/spec/core/build_spec.rb +922 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +656 -0
- data/spec/core/console_spec.rb +65 -0
- data/spec/core/doc_spec.rb +194 -0
- data/spec/core/extension_spec.rb +200 -0
- data/spec/core/project_spec.rb +736 -0
- data/spec/core/test_spec.rb +1131 -0
- data/spec/core/transport_spec.rb +452 -0
- data/spec/core/util_spec.rb +154 -0
- data/spec/ide/idea_spec.rb +1952 -0
- data/spec/java/commands_spec.rb +79 -0
- data/spec/java/compiler_spec.rb +274 -0
- data/spec/java/custom_pom_spec.rb +165 -0
- data/spec/java/doc_spec.rb +55 -0
- data/spec/java/packaging_spec.rb +786 -0
- data/spec/java/pom_spec.rb +162 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +224 -0
- data/spec/packaging/archive_spec.rb +686 -0
- data/spec/packaging/artifact_namespace_spec.rb +757 -0
- data/spec/packaging/artifact_spec.rb +1351 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +690 -0
- data/spec/sandbox.rb +166 -0
- data/spec/spec_helpers.rb +420 -0
- data/spec/version_requirement_spec.rb +145 -0
- data/spec/xpath_matchers.rb +123 -0
- metadata +295 -0
@@ -0,0 +1,162 @@
|
|
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
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
describe Buildr::POM do
|
20
|
+
before do
|
21
|
+
repositories.remote = 'http://buildr.apache.org/repository/noexist'
|
22
|
+
@app = 'group:pomapp:jar:1.0'
|
23
|
+
write artifact(@app).pom.to_s, <<-XML
|
24
|
+
<project>
|
25
|
+
<artifactId>pomapp</artifactId>
|
26
|
+
<groupId>group</groupId>
|
27
|
+
<dependencies>
|
28
|
+
<dependency>
|
29
|
+
<artifactId>library</artifactId>
|
30
|
+
<groupId>org.example</groupId>
|
31
|
+
<version>1.1</version>
|
32
|
+
<scope>runtime</scope>
|
33
|
+
<exclusions>
|
34
|
+
<exclusion>
|
35
|
+
<groupId>javax.mail</groupId>
|
36
|
+
<artifactId>mail</artifactId>
|
37
|
+
</exclusion>
|
38
|
+
</exclusions>
|
39
|
+
</dependency>
|
40
|
+
</dependencies>
|
41
|
+
</project>
|
42
|
+
XML
|
43
|
+
@library = 'org.example:library:jar:1.1'
|
44
|
+
write artifact(@library).pom.to_s, <<-XML
|
45
|
+
<project>
|
46
|
+
<artifactId>pomapp</artifactId>
|
47
|
+
<groupId>group</groupId>
|
48
|
+
<dependencies>
|
49
|
+
<dependency>
|
50
|
+
<artifactId>mail</artifactId>
|
51
|
+
<groupId>javax.mail</groupId>
|
52
|
+
<version>1.0</version>
|
53
|
+
</dependency>
|
54
|
+
<dependency>
|
55
|
+
<artifactId>foo</artifactId>
|
56
|
+
<groupId>org.example</groupId>
|
57
|
+
<version>2.0</version>
|
58
|
+
</dependency>
|
59
|
+
</dependencies>
|
60
|
+
</project>
|
61
|
+
XML
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should respect exclusions when computing transitive dependencies' do
|
65
|
+
pom = POM.load(artifact(@app).pom)
|
66
|
+
specs = %w[org.example:library:jar:1.1 org.example:foo:jar:2.0]
|
67
|
+
pom.dependencies.should eql(specs)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe Buildr::POM do
|
72
|
+
before do
|
73
|
+
repositories.remote = 'http://buildr.apache.org/repository/noexist'
|
74
|
+
@app = 'group:app:jar:1.0'
|
75
|
+
write artifact(@app).pom.to_s, <<-XML
|
76
|
+
<project>
|
77
|
+
<properties>
|
78
|
+
<a.version>${b.version}</a.version>
|
79
|
+
<b.version>1.1</b.version>
|
80
|
+
</properties>
|
81
|
+
<artifactId>app</artifactId>
|
82
|
+
<groupId>group</groupId>
|
83
|
+
<dependencies>
|
84
|
+
<dependency>
|
85
|
+
<artifactId>library</artifactId>
|
86
|
+
<groupId>org.example</groupId>
|
87
|
+
<version>${a.version}</version>
|
88
|
+
<scope>runtime</scope>
|
89
|
+
<exclusions>
|
90
|
+
<exclusion>
|
91
|
+
<groupId>javax.mail</groupId>
|
92
|
+
<artifactId>mail</artifactId>
|
93
|
+
</exclusion>
|
94
|
+
</exclusions>
|
95
|
+
</dependency>
|
96
|
+
</dependencies>
|
97
|
+
</project>
|
98
|
+
XML
|
99
|
+
@library = 'org.example:library:jar:1.1'
|
100
|
+
write artifact(@library).pom.to_s, <<-XML
|
101
|
+
<project>
|
102
|
+
<artifactId>app</artifactId>
|
103
|
+
<groupId>group</groupId>
|
104
|
+
<dependencies>
|
105
|
+
<dependency>
|
106
|
+
<artifactId>mail</artifactId>
|
107
|
+
<groupId>javax.mail</groupId>
|
108
|
+
<version>1.0</version>
|
109
|
+
</dependency>
|
110
|
+
<dependency>
|
111
|
+
<artifactId>foo</artifactId>
|
112
|
+
<groupId>org.example</groupId>
|
113
|
+
<version>2.0</version>
|
114
|
+
</dependency>
|
115
|
+
</dependencies>
|
116
|
+
</project>
|
117
|
+
XML
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should respect exclusions when computing transitive dependencies when the pom includes properties' do
|
121
|
+
pom = POM.load(artifact(@app).pom)
|
122
|
+
specs = {"a.version"=>"1.1", "b.version"=>"1.1", "project.groupId"=>"group", "pom.groupId"=>"group", "groupId"=>"group", "project.artifactId"=>"app", "pom.artifactId"=>"app", "artifactId"=>"app"}
|
123
|
+
pom.properties.should eql(specs)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe Buildr::POM do
|
128
|
+
before do
|
129
|
+
repositories.remote = 'http://buildr.apache.org/repository/noexist'
|
130
|
+
@parent = 'group:app-parent:jar:1.1.1'
|
131
|
+
write artifact(@parent).pom.to_s, <<-XML
|
132
|
+
<project>
|
133
|
+
<artifactId>app-parent</artifactId>
|
134
|
+
<groupId>group</groupId>
|
135
|
+
<version>1.1.1</version>
|
136
|
+
</project>
|
137
|
+
XML
|
138
|
+
@app = 'group:app:jar:1.0'
|
139
|
+
write artifact(@app).pom.to_s, <<-XML
|
140
|
+
<project>
|
141
|
+
<artifactId>app</artifactId>
|
142
|
+
<groupId>group</groupId>
|
143
|
+
<parent>
|
144
|
+
<groupId>group</groupId>
|
145
|
+
<artifactId>app-parent</artifactId>
|
146
|
+
<version>1.1.1</version>
|
147
|
+
</parent>
|
148
|
+
<dependencies>
|
149
|
+
<dependency>
|
150
|
+
<artifactId>library</artifactId>
|
151
|
+
<groupId>org.example</groupId>
|
152
|
+
<version>${project.parent.version}</version>
|
153
|
+
</dependency>
|
154
|
+
</dependencies>
|
155
|
+
</project>
|
156
|
+
XML
|
157
|
+
end
|
158
|
+
it "should manage to resolve the version from the parent version" do
|
159
|
+
pom = POM.load(artifact(@app).pom)
|
160
|
+
pom.dependencies.should include('org.example:library:jar:1.1.1')
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,257 @@
|
|
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
|
+
module TestCoverageHelper
|
21
|
+
def write_test options
|
22
|
+
write File.join(options[:in], "#{options[:for]}Test.java"),
|
23
|
+
"public class #{options[:for]}Test extends junit.framework.TestCase { public void test#{options[:for]}() { new #{options[:for]}(); } }"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Rspec matcher using file glob patterns.
|
27
|
+
class FileNamePatternMatcher
|
28
|
+
def initialize(pattern)
|
29
|
+
@expected_pattern = pattern
|
30
|
+
@pattern_matcher = lambda { |filename| File.fnmatch? pattern, filename }
|
31
|
+
end
|
32
|
+
|
33
|
+
def matches?(directory)
|
34
|
+
@actual_filenames = Dir[File.join(directory,'*')]
|
35
|
+
@actual_filenames.any? &@pattern_matcher
|
36
|
+
end
|
37
|
+
|
38
|
+
def failure_message
|
39
|
+
"Expected to find at least one element matching '#{@expected_pattern}' among #{@actual_filenames.inspect}, but found none"
|
40
|
+
end
|
41
|
+
|
42
|
+
def negative_failure_message
|
43
|
+
"Expected to find no element matching '#{@expected_pattern}' among #{@actual_filenames.inspect}, but found matching element(s) #{@actual_filenames.select(&@pattern_matcher).inspect}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Test if a directory contains at least one file matching a given glob pattern.
|
48
|
+
#
|
49
|
+
# For example, to check that a directory contains at least one HTML file:
|
50
|
+
# '/path/to/some/directory'.should have_files_matching('*.html')
|
51
|
+
def have_files_matching pattern
|
52
|
+
FileNamePatternMatcher.new pattern
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
RSpec.shared_examples 'test coverage tool' do
|
57
|
+
include TestCoverageHelper
|
58
|
+
|
59
|
+
def toolname
|
60
|
+
@tool_module.name.split('::').last.downcase
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_coverage_config
|
64
|
+
project('foo').send(toolname)
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'project-specific' do
|
68
|
+
|
69
|
+
before do
|
70
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
71
|
+
write_test :for=>'Foo', :in=>'src/test/java'
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'clean' do
|
75
|
+
before { define('foo') }
|
76
|
+
|
77
|
+
it 'should remove the instrumented directory' do
|
78
|
+
mkdir_p test_coverage_config.instrumented_dir.to_s
|
79
|
+
task('foo:clean').invoke
|
80
|
+
file(test_coverage_config.instrumented_dir).should_not exist
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should remove the reporting directory' do
|
84
|
+
mkdir_p test_coverage_config.report_dir
|
85
|
+
task('foo:clean').invoke
|
86
|
+
file(test_coverage_config.report_dir).should_not exist
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'instrumented directory' do
|
91
|
+
it 'should have a default value' do
|
92
|
+
define('foo')
|
93
|
+
test_coverage_config.instrumented_dir.should point_to_path('target/instrumented/classes')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should be overridable' do
|
97
|
+
toolname = toolname()
|
98
|
+
define('foo') { send(toolname).instrumented_dir = path_to('target/coverage/classes') }
|
99
|
+
test_coverage_config.instrumented_dir.should point_to_path('target/coverage/classes')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should be created during instrumentation' do
|
103
|
+
define('foo')
|
104
|
+
task("foo:#{toolname}:instrument").invoke
|
105
|
+
file(test_coverage_config.instrumented_dir).should exist
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'instrumentation' do
|
110
|
+
def instrumented_dir
|
111
|
+
file(test_coverage_config.instrumented_dir)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should happen after compile' do
|
115
|
+
define('foo')
|
116
|
+
lambda { task("foo:#{toolname}:instrument").invoke }.should run_task('foo:compile')
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should put classes from compile.target in the instrumented directory' do
|
120
|
+
define('foo')
|
121
|
+
task("foo:#{toolname}:instrument").invoke
|
122
|
+
Dir.entries(instrumented_dir.to_s).should == Dir.entries(project('foo').compile.target.to_s)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should touch instrumented directory if anything instrumented' do
|
126
|
+
a_long_time_ago = Time.now - 10
|
127
|
+
define('foo')
|
128
|
+
mkpath instrumented_dir.to_s
|
129
|
+
File.utime(a_long_time_ago, a_long_time_ago, instrumented_dir.to_s)
|
130
|
+
task("foo:#{toolname}:instrument").invoke
|
131
|
+
instrumented_dir.timestamp.should be_within(2).of(Time.now)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should not touch instrumented directory if nothing instrumented' do
|
135
|
+
a_long_time_ago = Time.now - 10
|
136
|
+
define('foo').compile.invoke
|
137
|
+
mkpath instrumented_dir.to_s
|
138
|
+
[project('foo').compile.target, instrumented_dir].map(&:to_s).each { |dir| File.utime(a_long_time_ago, a_long_time_ago, dir) }
|
139
|
+
task("foo:#{toolname}:instrument").invoke
|
140
|
+
instrumented_dir.timestamp.should be_within(2).of(a_long_time_ago)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'testing classpath' do
|
145
|
+
it 'should give priority to instrumented classes over non-instrumented ones' do
|
146
|
+
define('foo')
|
147
|
+
depends = project('foo').test.dependencies
|
148
|
+
depends.index(test_coverage_config.instrumented_dir).should < depends.index(project('foo').compile.target)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should have the test coverage tools artifacts' do
|
152
|
+
define('foo')
|
153
|
+
artifacts(@tool_module.dependencies).each { |artifact| project('foo').test.dependencies.should include(artifact) }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe 'html report' do
|
158
|
+
it 'should have html files' do
|
159
|
+
define('foo')
|
160
|
+
task("foo:#{toolname}:html").invoke
|
161
|
+
test_coverage_config.report_to(:html).should have_files_matching('*.html')
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should contain full source code, including comments' do
|
165
|
+
write 'src/main/java/Foo.java',
|
166
|
+
'public class Foo { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
|
167
|
+
define('foo')
|
168
|
+
task("foo:#{toolname}:html").invoke
|
169
|
+
html_report_contents = Dir[File.join(test_coverage_config.report_dir, '**/*.html')].map{|path|File.open(path).read}.join
|
170
|
+
html_report_contents.force_encoding('ascii-8bit')
|
171
|
+
html_report_contents.should =~ /TOKEN/
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe 'cross-project' do
|
177
|
+
describe 'reporting' do
|
178
|
+
before do
|
179
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
180
|
+
write 'bar/src/main/java/Bar.java', 'public class Bar {}'
|
181
|
+
write_test :for=>'Bar', :in=>'bar/src/test/java'
|
182
|
+
define('foo') { define('bar') }
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should have a default target' do
|
186
|
+
@tool_module.report_to.should point_to_path(File.join('reports', toolname))
|
187
|
+
end
|
188
|
+
|
189
|
+
describe 'in html' do
|
190
|
+
it 'should be a defined task' do
|
191
|
+
Rake::Task.task_defined?("#{toolname}:html").should be(true)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should happen after project instrumentation and testing' do
|
195
|
+
lambda { task("#{toolname}:html").invoke }.should run_tasks(["foo:#{toolname}:instrument", 'foo:bar:test'])
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should have html files' do
|
199
|
+
task("#{toolname}:html").invoke
|
200
|
+
@tool_module.report_to(:html).should have_files_matching('*.html')
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should contain full source code, including comments' do
|
204
|
+
write 'bar/src/main/java/Bar.java',
|
205
|
+
'public class Bar { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
|
206
|
+
task("#{toolname}:html").invoke
|
207
|
+
html_report_contents = Dir[File.join(@tool_module.report_to(:html), '**/*.html')].map{|path|File.read(path)}.join
|
208
|
+
html_report_contents.force_encoding('ascii-8bit') if RUBY_VERSION >= '1.9'
|
209
|
+
html_report_contents.should =~ /TOKEN/
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should handle gracefully a project with no source' do
|
213
|
+
define 'baz', :base_dir=>'baz'
|
214
|
+
task("#{toolname}:html").invoke
|
215
|
+
lambda { task("#{toolname}:html").invoke }.should_not raise_error
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe 'clean' do
|
221
|
+
it 'should remove the report directory' do
|
222
|
+
define('foo')
|
223
|
+
mkdir_p @tool_module.report_to
|
224
|
+
task("#{toolname}:clean").invoke
|
225
|
+
file(@tool_module.report_to).should_not exist
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'should be called when calling global clean' do
|
229
|
+
define('foo')
|
230
|
+
lambda { task('clean').invoke }.should run_task("#{toolname}:clean")
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe 'project with no source' do
|
236
|
+
it 'should not define an html report task' do
|
237
|
+
define 'foo'
|
238
|
+
Rake::Task.task_defined?("foo:#{toolname}:html").should be(false)
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should not raise an error when instrumenting' do
|
242
|
+
define('foo')
|
243
|
+
lambda { task("foo:#{toolname}:instrument").invoke }.should_not raise_error
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should not add the instrumented directory to the testing classpath' do
|
247
|
+
define 'foo'
|
248
|
+
depends = project('foo').test.dependencies
|
249
|
+
depends.should_not include(test_coverage_config.instrumented_dir)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should not add the test coverage tools artifacts to the testing classpath' do
|
253
|
+
define('foo')
|
254
|
+
@tool_module.dependencies.each { |artifact| project('foo').test.dependencies.should_not include(artifact) }
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -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
|
+
describe Buildr::TestNG do
|
20
|
+
it 'should be selectable in project' do
|
21
|
+
define 'foo' do
|
22
|
+
test.using(:testng)
|
23
|
+
test.framework.should eql(:testng)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should be selectable in parent project' do
|
28
|
+
write 'bar/src/test/java/TestCase.java'
|
29
|
+
define 'foo' do
|
30
|
+
test.using(:testng)
|
31
|
+
define 'bar'
|
32
|
+
end
|
33
|
+
project('foo:bar').test.framework.should eql(:testng)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should parse test classes in paths containing escaped sequences' do
|
37
|
+
write 'bar%2F/src/test/java/com/example/MyTest.java', <<-JAVA
|
38
|
+
package com.example;
|
39
|
+
@org.testng.annotations.Test
|
40
|
+
public class MyTest {
|
41
|
+
public void myTestMethod() { }
|
42
|
+
}
|
43
|
+
JAVA
|
44
|
+
define 'foo' do
|
45
|
+
define 'bar%2F' do
|
46
|
+
test.using(:testng)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
project('foo:bar%2F').test.invoke
|
50
|
+
project('foo:bar%2F').test.tests.should include('com.example.MyTest')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should include classes using TestNG annotations' do
|
54
|
+
write 'src/test/java/com/example/MyTest.java', <<-JAVA
|
55
|
+
package com.example;
|
56
|
+
@org.testng.annotations.Test
|
57
|
+
public class MyTest {
|
58
|
+
public void myTestMethod() { }
|
59
|
+
}
|
60
|
+
JAVA
|
61
|
+
write 'src/test/java/com/example/MyOtherTest.java', <<-JAVA
|
62
|
+
package com.example;
|
63
|
+
public class MyOtherTest {
|
64
|
+
@org.testng.annotations.Test
|
65
|
+
public void annotated() { }
|
66
|
+
}
|
67
|
+
JAVA
|
68
|
+
define('foo') { test.using(:testng) }
|
69
|
+
project('foo').test.invoke
|
70
|
+
project('foo').test.tests.should include('com.example.MyTest', 'com.example.MyOtherTest')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should ignore classes not using TestNG annotations' do
|
74
|
+
write 'src/test/java/NotATestClass.java', 'public class NotATestClass {}'
|
75
|
+
define('foo') { test.using(:testng) }
|
76
|
+
project('foo').test.invoke
|
77
|
+
project('foo').test.tests.should be_empty
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should ignore abstract test classes' do
|
81
|
+
write 'src/test/java/AbstractMyTest.java', 'public class AbstractMyTest {}'
|
82
|
+
define('foo') { test.using(:testng) }
|
83
|
+
project('foo').test.invoke
|
84
|
+
project('foo').test.tests.should be_empty
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should ignore inner classes' do
|
88
|
+
write 'src/test/java/InnerClassTest.java', <<-JAVA
|
89
|
+
@org.testng.annotations.Test
|
90
|
+
public class InnerClassTest {
|
91
|
+
public void myTestMethod() { }
|
92
|
+
|
93
|
+
public class InnerTest {
|
94
|
+
}
|
95
|
+
}
|
96
|
+
JAVA
|
97
|
+
define('foo') { test.using(:testng) }
|
98
|
+
project('foo').test.invoke
|
99
|
+
project('foo').test.tests.should eql(['InnerClassTest'])
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should pass when TestNG test case passes' do
|
103
|
+
write 'src/test/java/PassingTest.java', <<-JAVA
|
104
|
+
public class PassingTest {
|
105
|
+
@org.testng.annotations.Test
|
106
|
+
public void testNothing() {}
|
107
|
+
}
|
108
|
+
JAVA
|
109
|
+
define('foo') { test.using(:testng) }
|
110
|
+
lambda { project('foo').test.invoke }.should_not raise_error
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should fail when TestNG test case fails' do
|
114
|
+
write 'src/test/java/FailingTest.java', <<-JAVA
|
115
|
+
public class FailingTest {
|
116
|
+
@org.testng.annotations.Test
|
117
|
+
public void testNothing() {
|
118
|
+
org.testng.AssertJUnit.assertTrue(false);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
JAVA
|
122
|
+
define('foo') { test.using(:testng) }
|
123
|
+
lambda { project('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should fail when TestNG test case fails to compile' do
|
127
|
+
write 'src/test/java/FailingTest.java', <<-JAVA
|
128
|
+
public class FailingTest exte lasjw9jc930d;kl;kl
|
129
|
+
JAVA
|
130
|
+
define('foo') { test.using(:testng) }
|
131
|
+
lambda { project('foo').test.invoke }.should raise_error(RuntimeError)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should fail when multiple TestNG test case fail' do
|
135
|
+
write 'src/test/java/Failing1Test.java', <<-JAVA
|
136
|
+
public class Failing1Test {
|
137
|
+
@org.testng.annotations.Test
|
138
|
+
public void testNothing() {
|
139
|
+
org.testng.AssertJUnit.assertTrue(false);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
JAVA
|
143
|
+
write 'src/test/java/Failing2Test.java', <<-JAVA
|
144
|
+
public class Failing2Test {
|
145
|
+
@org.testng.annotations.Test
|
146
|
+
public void testNothing() {
|
147
|
+
org.testng.AssertJUnit.assertTrue(false);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
JAVA
|
151
|
+
define('foo') { test.using(:testng) }
|
152
|
+
lambda { project('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/)
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should report failed test names' do
|
156
|
+
write 'src/test/java/FailingTest.java', <<-JAVA
|
157
|
+
public class FailingTest {
|
158
|
+
@org.testng.annotations.Test
|
159
|
+
public void testNothing() {
|
160
|
+
org.testng.AssertJUnit.assertTrue(false);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
JAVA
|
164
|
+
define('foo') { test.using(:testng) }
|
165
|
+
project('foo').test.invoke rescue nil
|
166
|
+
project('foo').test.failed_tests.should include('FailingTest')
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should report to reports/testng' do
|
170
|
+
define('foo') { test.using(:testng) }
|
171
|
+
project('foo').test.report_to.should be(project('foo').file('reports/testng'))
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should generate reports' do
|
175
|
+
write 'src/test/java/PassingTest.java', <<-JAVA
|
176
|
+
public class PassingTest {
|
177
|
+
@org.testng.annotations.Test
|
178
|
+
public void testNothing() {}
|
179
|
+
}
|
180
|
+
JAVA
|
181
|
+
define('foo') { test.using(:testng) }
|
182
|
+
lambda { project('foo').test.invoke }.should change { File.exist?('reports/testng/index.html') }.to(true)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should include classes using TestNG annotations marked with a specific group' do
|
186
|
+
write 'src/test/java/com/example/AnnotatedClass.java', <<-JAVA
|
187
|
+
package com.example;
|
188
|
+
@org.testng.annotations.Test(groups={"included"})
|
189
|
+
public class AnnotatedClass { }
|
190
|
+
JAVA
|
191
|
+
write 'src/test/java/com/example/AnnotatedMethod.java', <<-JAVA
|
192
|
+
package com.example;
|
193
|
+
public class AnnotatedMethod {
|
194
|
+
@org.testng.annotations.Test
|
195
|
+
public void annotated() {
|
196
|
+
org.testng.AssertJUnit.assertTrue(false);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
JAVA
|
200
|
+
define('foo').test.using :testng, :groups=>['included']
|
201
|
+
lambda { project('foo').test.invoke }.should_not raise_error
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should exclude classes using TestNG annotations marked with a specific group' do
|
205
|
+
write 'src/test/java/com/example/AnnotatedClass.java', <<-JAVA
|
206
|
+
package com.example;
|
207
|
+
@org.testng.annotations.Test(groups={"excluded"})
|
208
|
+
public class AnnotatedClass {
|
209
|
+
public void annotated() {
|
210
|
+
org.testng.AssertJUnit.assertTrue(false);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
JAVA
|
214
|
+
write 'src/test/java/com/example/AnnotatedMethod.java', <<-JAVA
|
215
|
+
package com.example;
|
216
|
+
public class AnnotatedMethod {
|
217
|
+
@org.testng.annotations.Test(groups={"included"})
|
218
|
+
public void annotated() {}
|
219
|
+
}
|
220
|
+
JAVA
|
221
|
+
define('foo').test.using :testng, :excludegroups=>['excluded']
|
222
|
+
lambda { project('foo').test.invoke }.should_not raise_error
|
223
|
+
end
|
224
|
+
end
|