buildr 1.3.2-java → 1.3.3-java
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.
- 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 +93 -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
data/lib/buildr/java/groovyc.rb
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
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
|
-
module Buildr
|
|
18
|
-
module Compiler
|
|
19
|
-
# Groovyc compiler:
|
|
20
|
-
# compile.using(:groovyc)
|
|
21
|
-
#
|
|
22
|
-
# You need to require 'buildr/java/groovyc' if you need to use this compiler.
|
|
23
|
-
#
|
|
24
|
-
# Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
|
|
25
|
-
# and sets the target directory to target/classes (or target/test/classes).
|
|
26
|
-
#
|
|
27
|
-
# Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
|
|
28
|
-
# to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
|
|
29
|
-
# src/main/groovy directory, even though this compiler also looks in src/main/java
|
|
30
|
-
#
|
|
31
|
-
# Groovyc accepts the following options:
|
|
32
|
-
#
|
|
33
|
-
# * :encoding -- Encoding of source files
|
|
34
|
-
# * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
|
|
35
|
-
# * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
|
|
36
|
-
# * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
|
37
|
-
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
|
38
|
-
# * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
|
39
|
-
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
|
40
|
-
# * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
|
|
41
|
-
# * :stacktrace -- If true each compile error message will contain a stacktrace
|
|
42
|
-
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
|
43
|
-
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
|
44
|
-
# environment variable/global option.
|
|
45
|
-
# * :deprecation -- If true, shows deprecation messages. False by default.
|
|
46
|
-
# * :optimise -- Generates faster bytecode by applying optimisations to the program.
|
|
47
|
-
# * :source -- Source code compatibility.
|
|
48
|
-
# * :target -- Bytecode compatibility.
|
|
49
|
-
# * :javac -- Hash of options passed to the ant javac task
|
|
50
|
-
#
|
|
51
|
-
class Groovyc < Base
|
|
52
|
-
|
|
53
|
-
# The groovyc compiler jars are added to classpath at load time,
|
|
54
|
-
# if you want to customize artifact versions, you must set them on the
|
|
55
|
-
#
|
|
56
|
-
# artifact_ns['Buildr::Compiler::Groovyc'].groovy = '1.5.4'
|
|
57
|
-
#
|
|
58
|
-
# namespace before this file is required.
|
|
59
|
-
REQUIRES = ArtifactNamespace.for(self) do |ns|
|
|
60
|
-
ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.5.3'
|
|
61
|
-
ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.0'
|
|
62
|
-
ns.asm! 'asm:asm:jar:>=2.2'
|
|
63
|
-
ns.antlr! 'antlr:antlr:jar:>=2.7.7'
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
|
|
67
|
-
GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
|
|
68
|
-
JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
|
|
69
|
-
OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
|
|
70
|
-
|
|
71
|
-
class << self
|
|
72
|
-
def dependencies #:nodoc:
|
|
73
|
-
REQUIRES.artifacts
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def applies_to?(project, task) #:nodoc:
|
|
77
|
-
paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
|
|
78
|
-
paths.flatten!
|
|
79
|
-
# Just select if we find .groovy files
|
|
80
|
-
paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
Java.classpath << dependencies
|
|
85
|
-
|
|
86
|
-
specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
|
|
87
|
-
:target => 'classes', :target_ext => 'class', :packaging => :jar
|
|
88
|
-
|
|
89
|
-
def initialize(project, options) #:nodoc:
|
|
90
|
-
super
|
|
91
|
-
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
|
92
|
-
options[:deprecation] ||= false
|
|
93
|
-
options[:optimise] ||= false
|
|
94
|
-
options[:verbose] ||= Buildr.application.options.trace if options[:verbose].nil?
|
|
95
|
-
options[:warnings] = verbose if options[:warnings].nil?
|
|
96
|
-
options[:javac] = OpenObject.new if options[:javac].nil?
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# http://groovy.codehaus.org/The+groovyc+Ant+Task
|
|
100
|
-
def compile(sources, target, dependencies) #:nodoc:
|
|
101
|
-
return if Buildr.application.options.dryrun
|
|
102
|
-
Buildr.ant 'groovyc' do |ant|
|
|
103
|
-
classpath = dependencies | self.class.dependencies.map(&:to_s)
|
|
104
|
-
ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
|
|
105
|
-
ant.groovyc groovyc_options(sources, target) do
|
|
106
|
-
sources.each { |src| ant.src :path => src }
|
|
107
|
-
ant.classpath do
|
|
108
|
-
classpath.each { |dep| ant.pathelement :path => dep }
|
|
109
|
-
end
|
|
110
|
-
ant.javac(javac_options)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
private
|
|
116
|
-
def groovyc_options(sources, target)
|
|
117
|
-
check_options options, OPTIONS
|
|
118
|
-
groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
|
|
119
|
-
groovyc_options[:destdir] = File.expand_path(target)
|
|
120
|
-
groovyc_options
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def javac_options
|
|
124
|
-
check_options options, OPTIONS
|
|
125
|
-
javac_options = options.to_hash.only(*JAVAC_OPTIONS)
|
|
126
|
-
javac_options[:optimize] = (javac_options.delete(:optimise) || false)
|
|
127
|
-
javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
|
|
128
|
-
other = javac_options.delete(:javac) || {}
|
|
129
|
-
javac_options.merge!(other)
|
|
130
|
-
javac_options
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
Buildr::Compiler.compilers.unshift Buildr::Compiler::Groovyc
|
|
@@ -1,450 +0,0 @@
|
|
|
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 'buildr/core/build'
|
|
18
|
-
require 'buildr/core/compile'
|
|
19
|
-
require 'buildr/java/ant'
|
|
20
|
-
|
|
21
|
-
module Buildr
|
|
22
|
-
|
|
23
|
-
class TestFramework
|
|
24
|
-
module JavaTest
|
|
25
|
-
|
|
26
|
-
# Add buildr utilities (JavaTestFilter) to classpath
|
|
27
|
-
Java.classpath << File.join(File.dirname(__FILE__))
|
|
28
|
-
|
|
29
|
-
def self.included(mod)
|
|
30
|
-
super
|
|
31
|
-
mod.extend ClassMethods
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
# :call-seq:
|
|
36
|
-
# filter_classes(dependencies, criteria)
|
|
37
|
-
#
|
|
38
|
-
# Return a list of classnames that match the given criteria.
|
|
39
|
-
# The criteria parameter is a hash that must contain at least one of:
|
|
40
|
-
#
|
|
41
|
-
# * :class_names -- List of patterns to match against class name
|
|
42
|
-
# * :interfaces -- List of java interfaces or java classes
|
|
43
|
-
# * :class_annotations -- List of annotations on class level
|
|
44
|
-
# * :method_annotations -- List of annotations on method level
|
|
45
|
-
#
|
|
46
|
-
def filter_classes(dependencies, criteria = {})
|
|
47
|
-
return [] unless task.compile.target
|
|
48
|
-
target = task.compile.target.to_s
|
|
49
|
-
candidates = Dir["#{target}/**/*.class"].
|
|
50
|
-
map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.') }.
|
|
51
|
-
reject { |name| name =~ /\$/ }
|
|
52
|
-
result = []
|
|
53
|
-
if criteria[:class_names]
|
|
54
|
-
result.concat candidates.select { |name| criteria[:class_names].flatten.any? { |pat| pat === name } }
|
|
55
|
-
end
|
|
56
|
-
begin
|
|
57
|
-
Java.load
|
|
58
|
-
filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
|
|
59
|
-
if criteria[:interfaces]
|
|
60
|
-
filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String))
|
|
61
|
-
end
|
|
62
|
-
if criteria[:class_annotations]
|
|
63
|
-
filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
|
|
64
|
-
end
|
|
65
|
-
if criteria[:method_annotations]
|
|
66
|
-
filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
|
|
67
|
-
end
|
|
68
|
-
result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
|
|
69
|
-
rescue =>ex
|
|
70
|
-
puts "#{ex.class}: #{ex.message}" if verbose
|
|
71
|
-
raise
|
|
72
|
-
end
|
|
73
|
-
result.uniq
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
module ClassMethods
|
|
77
|
-
def applies_to?(project) #:nodoc:
|
|
78
|
-
project.test.compile.language == :java
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# JMock is available when using JUnit and TestNG, JBehave.
|
|
86
|
-
module JMock
|
|
87
|
-
# JMock version.
|
|
88
|
-
VERSION = '1.2.0' unless const_defined?('VERSION')
|
|
89
|
-
# JMock specification.
|
|
90
|
-
REQUIRES = ["jmock:jmock:jar:#{VERSION}"]
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Specs is available when using ScalaTest
|
|
94
|
-
module ScalaSpecs
|
|
95
|
-
# Specs version number.
|
|
96
|
-
VERSION = '1.2.9' unless const_defined?('VERSION')
|
|
97
|
-
# Specs artifact(s)
|
|
98
|
-
REQUIRES = ["org.specs:specs:jar:#{VERSION}"]
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# ScalaCheck is available when using ScalaTest
|
|
102
|
-
module ScalaCheck
|
|
103
|
-
# ScalaCheck version number.
|
|
104
|
-
VERSION = '1.3' unless const_defined?('VERSION')
|
|
105
|
-
# ScalaCheck artifact(s)
|
|
106
|
-
REQUIRES = ["org.scalacheck:scalacheck:jar:#{VERSION}"]
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# JUnit test framework, the default test framework for Java tests.
|
|
110
|
-
#
|
|
111
|
-
# Support the following options:
|
|
112
|
-
# * :fork -- If true/:once (default), fork for each test class. If :each, fork for each individual
|
|
113
|
-
# test case. If false, run all tests in the same VM (fast, but dangerous).
|
|
114
|
-
# * :clonevm -- If true clone the VM each time it is forked.
|
|
115
|
-
# * :properties -- Hash of system properties available to the test case.
|
|
116
|
-
# * :environment -- Hash of environment variables available to the test case.
|
|
117
|
-
# * :java_args -- Arguments passed as is to the JVM.
|
|
118
|
-
class JUnit < TestFramework::Base
|
|
119
|
-
|
|
120
|
-
# Used by the junit:report task. Access through JUnit#report if you want to set various
|
|
121
|
-
# options for that task, for example:
|
|
122
|
-
# JUnit.report.frames = false
|
|
123
|
-
class Report
|
|
124
|
-
|
|
125
|
-
# Ant-Trax required for running the JUnitReport task.
|
|
126
|
-
Java.classpath << "org.apache.ant:ant-trax:jar:#{Ant::VERSION}"
|
|
127
|
-
|
|
128
|
-
# Parameters passed to the Ant JUnitReport task.
|
|
129
|
-
attr_reader :params
|
|
130
|
-
# True (default) to produce a report using frames, false to produce a single-page report.
|
|
131
|
-
attr_accessor :frames
|
|
132
|
-
# Directory for the report style (defaults to using the internal style).
|
|
133
|
-
attr_accessor :style_dir
|
|
134
|
-
# Target directory for generated report.
|
|
135
|
-
attr_accessor :target
|
|
136
|
-
|
|
137
|
-
def initialize
|
|
138
|
-
@params = {}
|
|
139
|
-
@frames = true
|
|
140
|
-
@target = 'reports/junit'
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# :call-seq:
|
|
144
|
-
# generate(projects, target?)
|
|
145
|
-
#
|
|
146
|
-
# Generates a JUnit report for these projects (must run JUnit tests first) into the
|
|
147
|
-
# target directory. You can specify a target, or let it pick the default one from the
|
|
148
|
-
# target attribute.
|
|
149
|
-
def generate(projects, target = @target.to_s)
|
|
150
|
-
html_in = File.join(target, 'html')
|
|
151
|
-
rm_rf html_in ; mkpath html_in
|
|
152
|
-
|
|
153
|
-
Buildr.ant('junit-report') do |ant|
|
|
154
|
-
ant.junitreport :todir=>target do
|
|
155
|
-
projects.select { |project| project.test.framework == :junit }.
|
|
156
|
-
map { |project| project.test.report_to.to_s }.select { |path| File.exist?(path) }.
|
|
157
|
-
each { |path| ant.fileset(:dir=>path) { ant.include :name=>'TEST-*.xml' } }
|
|
158
|
-
options = { :format=>frames ? 'frames' : 'noframes' }
|
|
159
|
-
options[:styledir] = style_dir if style_dir
|
|
160
|
-
ant.report options.merge(:todir=>html_in) do
|
|
161
|
-
params.each { |key, value| ant.param :name=>key, :expression=>value }
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
class << self
|
|
170
|
-
|
|
171
|
-
# :call-seq:
|
|
172
|
-
# report()
|
|
173
|
-
#
|
|
174
|
-
# Returns the Report object used by the junit:report task. You can use this object to set
|
|
175
|
-
# various options that affect your report, for example:
|
|
176
|
-
# JUnit.report.frames = false
|
|
177
|
-
# JUnit.report.params['title'] = 'My App'
|
|
178
|
-
def report
|
|
179
|
-
@report ||= Report.new
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
# JUnit version number.
|
|
185
|
-
VERSION = '4.4' unless const_defined?('VERSION')
|
|
186
|
-
|
|
187
|
-
REQUIRES = ["junit:junit:jar:#{VERSION}"] + JMock::REQUIRES
|
|
188
|
-
|
|
189
|
-
# Ant-JUnit requires for JUnit and JUnit reports tasks.
|
|
190
|
-
Java.classpath << "org.apache.ant:ant-junit:jar:#{Ant::VERSION}"
|
|
191
|
-
|
|
192
|
-
include TestFramework::JavaTest
|
|
193
|
-
|
|
194
|
-
def tests(dependencies) #:nodoc:
|
|
195
|
-
filter_classes(dependencies,
|
|
196
|
-
:interfaces => %w{junit.framework.TestCase},
|
|
197
|
-
:class_annotations => %w{org.junit.runner.RunWith},
|
|
198
|
-
:method_annotations => %w{org.junit.Test})
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
def run(tests, dependencies) #:nodoc:
|
|
202
|
-
# Use Ant to execute the Junit tasks, gives us performance and reporting.
|
|
203
|
-
Buildr.ant('junit') do |ant|
|
|
204
|
-
case options[:fork]
|
|
205
|
-
when false
|
|
206
|
-
forking = {}
|
|
207
|
-
when :each
|
|
208
|
-
forking = { :fork=>true, :forkmode=>'perTest' }
|
|
209
|
-
when true, :once
|
|
210
|
-
forking = { :fork=>true, :forkmode=>'once' }
|
|
211
|
-
else
|
|
212
|
-
fail 'Option fork must be :once, :each or false.'
|
|
213
|
-
end
|
|
214
|
-
mkpath task.report_to.to_s
|
|
215
|
-
ant.junit forking.merge(:clonevm=>options[:clonevm] || false, :dir=>task.send(:project).path_to) do
|
|
216
|
-
ant.classpath :path=>dependencies.join(File::PATH_SEPARATOR)
|
|
217
|
-
(options[:properties] || []).each { |key, value| ant.sysproperty :key=>key, :value=>value }
|
|
218
|
-
(options[:environment] || []).each { |key, value| ant.env :key=>key, :value=>value }
|
|
219
|
-
Array(options[:java_args]).each { |value| ant.jvmarg :value=>value }
|
|
220
|
-
ant.formatter :type=>'plain'
|
|
221
|
-
ant.formatter :type=>'plain', :usefile=>false # log test
|
|
222
|
-
ant.formatter :type=>'xml'
|
|
223
|
-
ant.batchtest :todir=>task.report_to.to_s, :failureproperty=>'failed' do
|
|
224
|
-
ant.fileset :dir=>task.compile.target.to_s do
|
|
225
|
-
tests.each { |test| ant.include :name=>File.join(*test.split('.')).ext('class') }
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
return tests unless ant.project.getProperty('failed')
|
|
230
|
-
end
|
|
231
|
-
# But Ant doesn't tell us what went kaput, so we'll have to parse the test files.
|
|
232
|
-
tests.inject([]) do |passed, test|
|
|
233
|
-
report_file = File.join(task.report_to.to_s, "TEST-#{test}.txt")
|
|
234
|
-
if File.exist?(report_file)
|
|
235
|
-
report = File.read(report_file)
|
|
236
|
-
# The second line (if exists) is the status line and we scan it for its values.
|
|
237
|
-
status = (report.split("\n")[1] || '').scan(/(run|failures|errors):\s*(\d+)/i).
|
|
238
|
-
inject(Hash.new(0)) { |hash, pair| hash[pair[0].downcase.to_sym] = pair[1].to_i ; hash }
|
|
239
|
-
passed << test if status[:failures] == 0 && status[:errors] == 0
|
|
240
|
-
end
|
|
241
|
-
passed
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
namespace 'junit' do
|
|
246
|
-
desc "Generate JUnit tests report in #{report.target}"
|
|
247
|
-
task('report') do |task|
|
|
248
|
-
report.generate Project.projects
|
|
249
|
-
puts "Generated JUnit tests report in #{report.target}" if verbose
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
task('clean') { rm_rf report.target.to_s }
|
|
254
|
-
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
# TestNG test framework. To use in your project:
|
|
259
|
-
# test.using :testng
|
|
260
|
-
#
|
|
261
|
-
# Support the following options:
|
|
262
|
-
# * :properties -- Hash of properties passed to the test suite.
|
|
263
|
-
# * :java_args -- Arguments passed to the JVM.
|
|
264
|
-
class TestNG < TestFramework::Base
|
|
265
|
-
|
|
266
|
-
# TestNG version number.
|
|
267
|
-
VERSION = '5.7' unless const_defined?('VERSION')
|
|
268
|
-
# TestNG specification.
|
|
269
|
-
REQUIRES = ["org.testng:testng:jar:jdk15:#{VERSION}"] + JMock::REQUIRES
|
|
270
|
-
|
|
271
|
-
include TestFramework::JavaTest
|
|
272
|
-
|
|
273
|
-
def tests(dependencies) #:nodoc:
|
|
274
|
-
filter_classes(dependencies,
|
|
275
|
-
:class_annotations => %w{org.testng.annotations.Test},
|
|
276
|
-
:method_annotations => %w{org.testng.annotations.Test})
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
def run(tests, dependencies) #:nodoc:
|
|
280
|
-
cmd_args = [ 'org.testng.TestNG', '-sourcedir', task.compile.sources.join(';'), '-suitename', task.send(:project).name ]
|
|
281
|
-
cmd_args << '-d' << task.report_to.to_s
|
|
282
|
-
cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args],
|
|
283
|
-
:classpath=>dependencies }
|
|
284
|
-
tests.inject([]) do |passed, test|
|
|
285
|
-
begin
|
|
286
|
-
Java::Commands.java cmd_args, '-testclass', test, cmd_options.merge(:name=>test)
|
|
287
|
-
passed << test
|
|
288
|
-
rescue
|
|
289
|
-
passed
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
# ScalaTest framework, the default test framework for Scala tests.
|
|
297
|
-
#
|
|
298
|
-
# Support the following options:
|
|
299
|
-
# * :properties -- Hash of system properties available to the test case.
|
|
300
|
-
# * :environment -- Hash of environment variables available to the test case.
|
|
301
|
-
# * :java_args -- Arguments passed as is to the JVM.
|
|
302
|
-
class ScalaTest < TestFramework::Base
|
|
303
|
-
|
|
304
|
-
class << self
|
|
305
|
-
# ScalaTest version number.
|
|
306
|
-
VERSION = '0.9.3' unless const_defined?('VERSION')
|
|
307
|
-
|
|
308
|
-
# ScalaTest dependencies
|
|
309
|
-
DEPENDS = ["org.scalatest:scalatest:jar:#{VERSION}"] +
|
|
310
|
-
JMock::REQUIRES +
|
|
311
|
-
ScalaSpecs::REQUIRES +
|
|
312
|
-
ScalaCheck::REQUIRES
|
|
313
|
-
|
|
314
|
-
ENABLED = DEPENDS.all? { |d| File.exist?(Buildr::Repositories.instance.locate(d)) }
|
|
315
|
-
|
|
316
|
-
desc "Download Scala artifacts"
|
|
317
|
-
task "buildr:scala:download" do
|
|
318
|
-
ScalaTest.download_dependencies
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
def required_artifacts
|
|
322
|
-
ENABLED ? DEPENDS : []
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
def download_dependencies
|
|
326
|
-
DEPENDS.each { |d| Buildr.artifact(d).invoke }
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
def applies_to?(project) #:nodoc:
|
|
330
|
-
if project.test.compile.language == :scala && !ENABLED
|
|
331
|
-
download_dependencies
|
|
332
|
-
fail "You must re-run buildr after downloading Scala artifacts for the first time"
|
|
333
|
-
end
|
|
334
|
-
project.test.compile.language == :scala
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
def available?(artifact_spec) #:nodoc:
|
|
338
|
-
File.exist?(Buildr::Repositories.instance.locate(artifact_spec))
|
|
339
|
-
end
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
REQUIRES = required_artifacts
|
|
343
|
-
|
|
344
|
-
# ScalaTest ant task
|
|
345
|
-
Java.classpath << "org.apache.ant:ant-junit:jar:#{Ant::VERSION}"
|
|
346
|
-
Java.classpath << REQUIRES
|
|
347
|
-
|
|
348
|
-
include TestFramework::JavaTest
|
|
349
|
-
|
|
350
|
-
# annotation-based group inclusion
|
|
351
|
-
attr_accessor :group_includes
|
|
352
|
-
|
|
353
|
-
# annotation-based group exclusion
|
|
354
|
-
attr_accessor :group_excludes
|
|
355
|
-
|
|
356
|
-
def initialize(test_task, options)
|
|
357
|
-
super
|
|
358
|
-
@group_includes = []
|
|
359
|
-
@group_excludes = []
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
def tests(dependencies) #:nodoc:
|
|
363
|
-
suites = filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
|
|
364
|
-
# we should really filter using :class => %w{org.specs.Specification} instead of naming convention
|
|
365
|
-
specs = filter_classes(dependencies, :class_names => [/Specs?$/])
|
|
366
|
-
[suites, specs].flatten
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
def run(tests, dependencies) #:nodoc:
|
|
370
|
-
mkpath task.report_to.to_s
|
|
371
|
-
success = []
|
|
372
|
-
scalatest = tests.select { |t| t !~ /Specs?$/ }
|
|
373
|
-
specs = tests.select { |t| t =~ /Specs?$/ }
|
|
374
|
-
|
|
375
|
-
# Specs
|
|
376
|
-
#options = { :nostacktrace => false }.merge(options)
|
|
377
|
-
nostacktrace = (options[:nostacktrace]) ? "-ns" : ""
|
|
378
|
-
cmd_options = { :properties => options[:properties],
|
|
379
|
-
:java_args => options[:java_args],
|
|
380
|
-
:classpath => dependencies}
|
|
381
|
-
specs.each do |spec|
|
|
382
|
-
Java.load
|
|
383
|
-
begin
|
|
384
|
-
Java::Commands.java(spec, {:classpath => dependencies})
|
|
385
|
-
rescue => e
|
|
386
|
-
print e.message
|
|
387
|
-
else
|
|
388
|
-
success << spec
|
|
389
|
-
end
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
# ScalaTest
|
|
393
|
-
reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
|
|
394
|
-
scalatest.each do |suite|
|
|
395
|
-
puts "ScalaTest #{suite.inspect}" if verbose
|
|
396
|
-
# Use Ant to execute the ScalaTest task, gives us performance and reporting.
|
|
397
|
-
reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt")
|
|
398
|
-
Buildr.ant('scalatest') do |ant|
|
|
399
|
-
ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask'
|
|
400
|
-
ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do
|
|
401
|
-
ant.suite :classname=>suite
|
|
402
|
-
ant.reporter :type=>'stdout', :config=>reporter_options
|
|
403
|
-
ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
|
|
404
|
-
ant.includes group_includes.join(" ") if group_includes
|
|
405
|
-
ant.excludes group_excludes.join(" ") if group_excludes
|
|
406
|
-
(options[:properties] || []).each { |name, value| ant.property :name=>name, :value=>value }
|
|
407
|
-
end
|
|
408
|
-
end
|
|
409
|
-
|
|
410
|
-
# Parse for failures, errors, etc.
|
|
411
|
-
# This is a bit of a pain right now because ScalaTest doesn't flush its
|
|
412
|
-
# output synchronously before the Ant test finishes so we have to loop
|
|
413
|
-
# and wait for an indication that the test run was completed.
|
|
414
|
-
failed = false
|
|
415
|
-
completed = false
|
|
416
|
-
wait = 0
|
|
417
|
-
while (!completed) do
|
|
418
|
-
File.open(reportFile, "r") do |input|
|
|
419
|
-
while (line = input.gets) do
|
|
420
|
-
failed = (line =~ /(TEST FAILED -)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
|
|
421
|
-
completed |= (line =~ /Run completed\./)
|
|
422
|
-
break if (failed || completed)
|
|
423
|
-
end
|
|
424
|
-
end
|
|
425
|
-
wait += 1
|
|
426
|
-
break if (failed || wait > 10)
|
|
427
|
-
unless completed
|
|
428
|
-
sleep(1)
|
|
429
|
-
end
|
|
430
|
-
end
|
|
431
|
-
success << suite if (completed && !failed)
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
success
|
|
435
|
-
end # run
|
|
436
|
-
|
|
437
|
-
end # ScalaTest
|
|
438
|
-
|
|
439
|
-
end # Buildr
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
Buildr::TestFramework << Buildr::JUnit
|
|
443
|
-
Buildr::TestFramework << Buildr::TestNG
|
|
444
|
-
Buildr::TestFramework << Buildr::ScalaTest
|
|
445
|
-
|
|
446
|
-
# Backward compatibility crap.
|
|
447
|
-
Buildr::JUnit::JUNIT_REQUIRES = Buildr::JUnit::REQUIRES
|
|
448
|
-
Buildr::TestNG::TestNG_REQUIRES = Buildr::TestNG::REQUIRES
|
|
449
|
-
Java::JUnit = Buildr::JUnit
|
|
450
|
-
Java::TestNG = Buildr::TestNG
|