assaf-buildr 1.3.3
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 +887 -0
- data/DISCLAIMER +7 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +146 -0
- data/Rakefile +62 -0
- data/_buildr +38 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +236 -0
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -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 +817 -0
- data/addon/buildr/openjpa.rb +90 -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/xmlbeans.rb +93 -0
- data/bin/buildr +28 -0
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +58 -0
- data/doc/css/default.css +228 -0
- data/doc/css/print.css +100 -0
- data/doc/css/syntax.css +52 -0
- data/doc/images/apache-incubator-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.tif +0 -0
- data/doc/pages/artifacts.textile +207 -0
- data/doc/pages/building.textile +240 -0
- data/doc/pages/contributing.textile +208 -0
- data/doc/pages/download.textile +62 -0
- data/doc/pages/extending.textile +175 -0
- data/doc/pages/getting_started.textile +273 -0
- data/doc/pages/index.textile +42 -0
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +286 -0
- data/doc/pages/packaging.textile +427 -0
- data/doc/pages/projects.textile +274 -0
- data/doc/pages/recipes.textile +103 -0
- data/doc/pages/settings_profiles.textile +274 -0
- data/doc/pages/testing.textile +212 -0
- data/doc/pages/troubleshooting.textile +103 -0
- data/doc/pages/whats_new.textile +323 -0
- data/doc/print.haml +51 -0
- data/doc/print.toc.yaml +29 -0
- data/doc/scripts/buildr-git.rb +412 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +56 -0
- data/doc/site.toc.yaml +47 -0
- data/etc/KEYS +151 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +35 -0
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +489 -0
- data/lib/buildr/core/application_cli.rb +139 -0
- data/lib/buildr/core/build.rb +311 -0
- data/lib/buildr/core/checks.rb +382 -0
- data/lib/buildr/core/common.rb +154 -0
- data/lib/buildr/core/compile.rb +596 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +892 -0
- data/lib/buildr/core/test.rb +715 -0
- data/lib/buildr/core/transports.rb +558 -0
- data/lib/buildr/core/util.rb +289 -0
- 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.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +212 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +189 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +92 -0
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +211 -0
- data/lib/buildr/java/compiler.rb +348 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/jruby.rb +117 -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 +119 -0
- data/lib/buildr/java/packaging.rb +713 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/buildr/packaging/artifact.rb +730 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/buildr/packaging/tar.rb +104 -0
- data/lib/buildr/packaging/zip.rb +722 -0
- 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 +191 -0
- data/rakelib/changelog.rake +57 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +65 -0
- data/rakelib/rspec.rake +83 -0
- data/rakelib/rubyforge.rake +53 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +86 -0
- data/rakelib/stage.rake +48 -0
- 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/core/application_spec.rb +412 -0
- data/spec/core/artifact_namespace_spec.rb +646 -0
- data/spec/core/build_spec.rb +415 -0
- data/spec/core/checks_spec.rb +537 -0
- data/spec/core/common_spec.rb +664 -0
- data/spec/core/compile_spec.rb +566 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +754 -0
- data/spec/core/test_spec.rb +1091 -0
- data/spec/core/transport_spec.rb +500 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +239 -0
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/java/ant.rb +28 -0
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/java_spec.rb +88 -0
- data/spec/java/packaging_spec.rb +1103 -0
- data/spec/java/tests_spec.rb +466 -0
- data/spec/packaging/archive_spec.rb +503 -0
- data/spec/packaging/artifact_spec.rb +754 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +589 -0
- data/spec/sandbox.rb +137 -0
- data/spec/scala/compiler_spec.rb +228 -0
- data/spec/scala/tests_spec.rb +215 -0
- data/spec/spec_helpers.rb +304 -0
- data/spec/version_requirement_spec.rb +123 -0
- metadata +369 -0
data/spec/sandbox.rb
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
# The local repository we use for testing is void of any artifacts, which will break given
|
|
18
|
+
# that the code requires several artifacts. So we establish them first using the real local
|
|
19
|
+
# repository and cache these across test cases.
|
|
20
|
+
Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
|
|
21
|
+
repositories.remote << 'http://repo1.maven.org/maven2'
|
|
22
|
+
repositories.remote << 'http://scala-tools.org/repo-releases'
|
|
23
|
+
|
|
24
|
+
require 'buildr/groovy'
|
|
25
|
+
require 'buildr/scala'
|
|
26
|
+
|
|
27
|
+
Java.load # Anything added to the classpath.
|
|
28
|
+
task('buildr:scala:download').invoke
|
|
29
|
+
artifacts(TestFramework.frameworks.map(&:dependencies).flatten, JUnit.ant_taskdef).each { |a| file(a).invoke }
|
|
30
|
+
|
|
31
|
+
ENV['HOME'] = File.expand_path('tmp/home')
|
|
32
|
+
|
|
33
|
+
# We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
|
|
34
|
+
# and restoring everything to its previous state after the test. Damn state changes.
|
|
35
|
+
module Sandbox
|
|
36
|
+
|
|
37
|
+
class << self
|
|
38
|
+
attr_reader :tasks, :rules
|
|
39
|
+
|
|
40
|
+
def included(spec)
|
|
41
|
+
spec.before(:each) { sandbox }
|
|
42
|
+
spec.after(:each) { reset }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Require an addon without letting its callbacks pollute the Project class.
|
|
46
|
+
def require_addon addon_require_path
|
|
47
|
+
project_callbacks_without_addon = Project.class_eval { @callbacks }.dup
|
|
48
|
+
begin
|
|
49
|
+
require addon_require_path
|
|
50
|
+
ensure
|
|
51
|
+
Project.class_eval { @callbacks = project_callbacks_without_addon }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
@tasks = Buildr.application.tasks.collect do |original|
|
|
57
|
+
prerequisites = original.send(:prerequisites).map(&:to_s)
|
|
58
|
+
actions = original.instance_eval { @actions }.clone
|
|
59
|
+
lambda do
|
|
60
|
+
original.class.send(:define_task, original.name=>prerequisites).tap do |task|
|
|
61
|
+
task.comment = original.comment
|
|
62
|
+
actions.each { |action| task.enhance &action }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
@rules = Buildr.application.instance_variable_get(:@rules)
|
|
67
|
+
|
|
68
|
+
def sandbox
|
|
69
|
+
@_sandbox = {}
|
|
70
|
+
|
|
71
|
+
# Create a temporary directory where we can create files, e.g,
|
|
72
|
+
# for projects, compilation. We need a place that does not depend
|
|
73
|
+
# on the current directory.
|
|
74
|
+
@_sandbox[:original_dir] = Dir.pwd
|
|
75
|
+
temp = File.join(File.dirname(__FILE__), '../tmp')
|
|
76
|
+
FileUtils.mkpath temp
|
|
77
|
+
Dir.chdir temp
|
|
78
|
+
|
|
79
|
+
Buildr.application = Buildr::Application.new
|
|
80
|
+
Sandbox.tasks.each { |block| block.call }
|
|
81
|
+
Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
|
|
82
|
+
Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
|
|
83
|
+
|
|
84
|
+
@_sandbox[:load_path] = $LOAD_PATH.clone
|
|
85
|
+
@_sandbox[:loaded_features] = $LOADED_FEATURES.clone
|
|
86
|
+
|
|
87
|
+
# Later on we'll want to lose all the on_define created during the test.
|
|
88
|
+
@_sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
|
|
89
|
+
@_sandbox[:callbacks] = Project.class_eval { (@callbacks || []).dup }
|
|
90
|
+
@_sandbox[:layout] = Layout.default.clone
|
|
91
|
+
|
|
92
|
+
# Create a local repository we can play with. However, our local repository will be void
|
|
93
|
+
# of some essential artifacts (e.g. JUnit artifacts required by build task), so we create
|
|
94
|
+
# these first (see above) and keep them across test cases.
|
|
95
|
+
@_sandbox[:artifacts] = Artifact.class_eval { @artifacts }.clone
|
|
96
|
+
Buildr.repositories.local = File.expand_path('repository')
|
|
97
|
+
ENV['HOME'] = File.expand_path('home')
|
|
98
|
+
|
|
99
|
+
@_sandbox[:env_keys] = ENV.keys
|
|
100
|
+
['DEBUG', 'TEST', 'HTTP_PROXY', 'USER'].each { |k| ENV.delete(k) ; ENV.delete(k.downcase) }
|
|
101
|
+
|
|
102
|
+
# Remove testing local repository, and reset all repository settings.
|
|
103
|
+
Buildr.repositories.instance_eval do
|
|
104
|
+
@local = @remote = @release_to = nil
|
|
105
|
+
end
|
|
106
|
+
Buildr.options.proxy.http = nil
|
|
107
|
+
|
|
108
|
+
# Don't output crap to the console.
|
|
109
|
+
trace false
|
|
110
|
+
verbose false
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Call this from teardown.
|
|
114
|
+
def reset
|
|
115
|
+
# Get rid of all the projects and the on_define blocks we used.
|
|
116
|
+
Project.clear
|
|
117
|
+
on_define = @_sandbox[:on_define]
|
|
118
|
+
Project.class_eval { @on_define = on_define }
|
|
119
|
+
callbacks = @_sandbox[:callbacks]
|
|
120
|
+
Project.class_eval { @callbacks = callbacks }
|
|
121
|
+
Layout.default = @_sandbox[:layout].clone
|
|
122
|
+
|
|
123
|
+
$LOAD_PATH.replace @_sandbox[:load_path]
|
|
124
|
+
$LOADED_FEATURES.replace @_sandbox[:loaded_features]
|
|
125
|
+
FileUtils.rm_rf Dir.pwd
|
|
126
|
+
|
|
127
|
+
# Get rid of all artifacts.
|
|
128
|
+
@_sandbox[:artifacts].tap { |artifacts| Artifact.class_eval { @artifacts = artifacts } }
|
|
129
|
+
|
|
130
|
+
# Restore options.
|
|
131
|
+
Buildr.options.test = nil
|
|
132
|
+
(ENV.keys - @_sandbox[:env_keys]).each { |key| ENV.delete key }
|
|
133
|
+
|
|
134
|
+
Dir.chdir @_sandbox[:original_dir]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
describe 'scalac compiler' do
|
|
21
|
+
it 'should identify itself from source directories' do
|
|
22
|
+
write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val i = 1 }'
|
|
23
|
+
define('foo').compile.compiler.should eql(:scalac)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should report the language as :scala' do
|
|
27
|
+
define('foo').compile.using(:scalac).language.should eql(:scala)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should set the target directory to target/classes' do
|
|
31
|
+
define 'foo' do
|
|
32
|
+
lambda { compile.using(:scalac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should not override existing target directory' do
|
|
37
|
+
define 'foo' do
|
|
38
|
+
compile.into('classes')
|
|
39
|
+
lambda { compile.using(:scalac) }.should_not change { compile.target }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should not change existing list of sources' do
|
|
44
|
+
define 'foo' do
|
|
45
|
+
compile.from('sources')
|
|
46
|
+
lambda { compile.using(:scalac) }.should_not change { compile.sources }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should include as classpath dependency' do
|
|
51
|
+
write 'src/dependency/Dependency.scala', 'class Dependency {}'
|
|
52
|
+
define 'dependency', :version=>'1.0' do
|
|
53
|
+
compile.from('src/dependency').into('target/dependency')
|
|
54
|
+
package(:jar)
|
|
55
|
+
end
|
|
56
|
+
write 'src/test/DependencyTest.scala', 'class DependencyTest { var d: Dependency = _ }'
|
|
57
|
+
lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
|
|
58
|
+
file('target/classes/DependencyTest.class').should exist
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def define_test1_project
|
|
62
|
+
write 'src/main/scala/com/example/Test1.scala', 'package com.example; class Test1 { val i = 1 }'
|
|
63
|
+
define 'test1', :version=>'1.0' do
|
|
64
|
+
package(:jar)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should compile a simple .scala file into a .class file' do
|
|
69
|
+
define_test1_project
|
|
70
|
+
task('test1:compile').invoke
|
|
71
|
+
file('target/classes/com/example/Test1.class').should exist
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should package .class into a .jar file' do
|
|
75
|
+
define_test1_project
|
|
76
|
+
task('test1:package').invoke
|
|
77
|
+
file('target/test1-1.0.jar').should exist
|
|
78
|
+
Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
|
|
79
|
+
zip.file.exist?('com/example/Test1.class').should be_true
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
describe 'scalac compiler options' do
|
|
87
|
+
def compile_task
|
|
88
|
+
@compile_task ||= define('foo').compile.using(:scalac)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def scalac_args
|
|
92
|
+
compile_task.instance_eval { @compiler }.send(:scalac_args)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'should set warnings option to false by default' do
|
|
96
|
+
compile_task.options.warnings.should be_false
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'should set wranings option to true when running with --verbose option' do
|
|
100
|
+
verbose true
|
|
101
|
+
compile_task.options.warnings.should be_true
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'should use -nowarn argument when warnings is false' do
|
|
105
|
+
compile_task.using(:warnings=>false)
|
|
106
|
+
scalac_args.should include('-nowarn')
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'should not use -nowarn argument when warnings is true' do
|
|
110
|
+
compile_task.using(:warnings=>true)
|
|
111
|
+
scalac_args.should_not include('-nowarn')
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'should not use -verbose argument by default' do
|
|
115
|
+
scalac_args.should_not include('-verbose')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'should use -verbose argument when running with --trace option' do
|
|
119
|
+
trace true
|
|
120
|
+
scalac_args.should include('-verbose')
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'should set debug option to true by default' do
|
|
124
|
+
compile_task.options.debug.should be_true
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'should set debug option to false based on Buildr.options' do
|
|
128
|
+
Buildr.options.debug = false
|
|
129
|
+
compile_task.options.debug.should be_false
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'should set debug option to false based on debug environment variable' do
|
|
133
|
+
ENV['debug'] = 'no'
|
|
134
|
+
compile_task.options.debug.should be_false
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'should set debug option to false based on DEBUG environment variable' do
|
|
138
|
+
ENV['DEBUG'] = 'no'
|
|
139
|
+
compile_task.options.debug.should be_false
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'should use -g argument when debug option is true' do
|
|
143
|
+
compile_task.using(:debug=>true)
|
|
144
|
+
scalac_args.should include('-g')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'should not use -g argument when debug option is false' do
|
|
148
|
+
compile_task.using(:debug=>false)
|
|
149
|
+
scalac_args.should_not include('-g')
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it 'should set deprecation option to false by default' do
|
|
153
|
+
compile_task.options.deprecation.should be_false
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'should use -deprecation argument when deprecation is true' do
|
|
157
|
+
compile_task.using(:deprecation=>true)
|
|
158
|
+
scalac_args.should include('-deprecation')
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'should not use -deprecation argument when deprecation is false' do
|
|
162
|
+
compile_task.using(:deprecation=>false)
|
|
163
|
+
scalac_args.should_not include('-deprecation')
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'should set optimise option to false by default' do
|
|
167
|
+
compile_task.options.optimise.should be_false
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'should use -optimise argument when deprecation is true' do
|
|
171
|
+
compile_task.using(:optimise=>true)
|
|
172
|
+
scalac_args.should include('-optimise')
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it 'should not use -optimise argument when deprecation is false' do
|
|
176
|
+
compile_task.using(:optimise=>false)
|
|
177
|
+
scalac_args.should_not include('-optimise')
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'should not set target option by default' do
|
|
181
|
+
compile_task.options.target.should be_nil
|
|
182
|
+
scalac_args.should_not include('-target')
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'should use -target:xxx argument if target option set' do
|
|
186
|
+
compile_task.using(:target=>'1.5')
|
|
187
|
+
scalac_args.should include('-target:jvm-1.5')
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'should not set other option by default' do
|
|
191
|
+
compile_task.options.other.should be_nil
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it 'should pass other argument if other option is string' do
|
|
195
|
+
compile_task.using(:other=>'-unchecked')
|
|
196
|
+
scalac_args.should include('-unchecked')
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it 'should pass other argument if other option is array' do
|
|
200
|
+
compile_task.using(:other=>['-unchecked', '-Xprint-types'])
|
|
201
|
+
scalac_args.should include('-unchecked', '-Xprint-types')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it 'should complain about options it doesn\'t know' do
|
|
205
|
+
write 'source/Test.scala', 'class Test {}'
|
|
206
|
+
compile_task.using(:unknown=>'option')
|
|
207
|
+
lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it 'should inherit options from parent' do
|
|
211
|
+
define 'foo' do
|
|
212
|
+
compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :target=>'1.4')
|
|
213
|
+
define 'bar' do
|
|
214
|
+
compile.using(:scalac)
|
|
215
|
+
compile.options.warnings.should be_true
|
|
216
|
+
compile.options.debug.should be_true
|
|
217
|
+
compile.options.deprecation.should be_true
|
|
218
|
+
compile.options.target.should eql('1.4')
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
after do
|
|
224
|
+
Buildr.options.debug = nil
|
|
225
|
+
ENV.delete "debug"
|
|
226
|
+
ENV.delete "DEBUG"
|
|
227
|
+
end
|
|
228
|
+
end
|
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
# TODO's
|
|
20
|
+
# -test w/ Specs
|
|
21
|
+
# -test w/ ScalaCheck
|
|
22
|
+
# -failing test
|
|
23
|
+
# -test passing System props
|
|
24
|
+
# -test passing ENV variables
|
|
25
|
+
# -test exclude group
|
|
26
|
+
# -test include Suite's
|
|
27
|
+
# -test exclude Suite's
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
describe Buildr::Scala::ScalaTest do
|
|
31
|
+
it 'should be the default test framework when test cases are in Scala' do
|
|
32
|
+
write 'src/test/scala/com/example/MySuite.scala', <<-SCALA
|
|
33
|
+
package com.example
|
|
34
|
+
import org.scalatest.FunSuite
|
|
35
|
+
class MySuite extends FunSuite {
|
|
36
|
+
test("addition") {
|
|
37
|
+
val sum = 1 + 1
|
|
38
|
+
assert(sum === 2)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
SCALA
|
|
42
|
+
define 'foo'
|
|
43
|
+
project('foo').test.framework.should eql(:scalatest)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'should be picked if the test language is Scala' do
|
|
47
|
+
define 'foo' do
|
|
48
|
+
test.compile.using(:scalac)
|
|
49
|
+
test.framework.should eql(:scalatest)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'should include Scalatest dependencies' do
|
|
54
|
+
define('foo') { test.using(:scalatest) }
|
|
55
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::ScalaTest.dependencies))
|
|
56
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::ScalaTest.dependencies))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'should include JMock dependencies' do
|
|
60
|
+
define('foo') { test.using(:scalatest) }
|
|
61
|
+
project('foo').test.compile.dependencies.should include(*artifacts(JMock.dependencies))
|
|
62
|
+
project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should include Specs dependencies' do
|
|
66
|
+
define('foo') { test.using(:scalatest) }
|
|
67
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::ScalaSpecs.dependencies))
|
|
68
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::ScalaSpecs.dependencies))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should include ScalaCheck dependencies' do
|
|
72
|
+
define('foo') { test.using(:scalatest) }
|
|
73
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::ScalaCheck.dependencies))
|
|
74
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::ScalaCheck.dependencies))
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'should include public classes extending org.scalatest.FunSuite' do
|
|
78
|
+
write 'src/test/scala/com/example/MySuite.scala', <<-SCALA
|
|
79
|
+
package com.example
|
|
80
|
+
import org.scalatest.FunSuite
|
|
81
|
+
class MySuite extends FunSuite {
|
|
82
|
+
test("addition") {
|
|
83
|
+
val sum = 1 + 1
|
|
84
|
+
assert(sum === 2)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
SCALA
|
|
88
|
+
define('foo').test.invoke
|
|
89
|
+
project('foo').test.tests.should include('com.example.MySuite')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should ignore classes not extending org.scalatest.FunSuite' do
|
|
93
|
+
write 'src/test/scala/com/example/NotASuite.scala', <<-SCALA
|
|
94
|
+
package com.example
|
|
95
|
+
class Another {
|
|
96
|
+
}
|
|
97
|
+
SCALA
|
|
98
|
+
define('foo').test.invoke
|
|
99
|
+
project('foo').test.tests.should be_empty
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'should ignore inner classes' do
|
|
103
|
+
write 'src/test/scala/com/example/InnerClassTest.scala', <<-SCALA
|
|
104
|
+
package com.example
|
|
105
|
+
import org.scalatest.FunSuite
|
|
106
|
+
class InnerClassTest extends FunSuite {
|
|
107
|
+
test("addition") {
|
|
108
|
+
val sum = 1 + 1
|
|
109
|
+
assert(sum === 2)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
class InnerSuite extends FunSuite {
|
|
113
|
+
test("addition") {
|
|
114
|
+
val sum = 1 + 1
|
|
115
|
+
assert(sum === 2)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
SCALA
|
|
120
|
+
define('foo').test.invoke
|
|
121
|
+
project('foo').test.tests.should eql(['com.example.InnerClassTest'])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should pass when ScalaTest test case passes' do
|
|
125
|
+
write 'src/test/scala/PassingSuite.scala', <<-SCALA
|
|
126
|
+
class PassingSuite extends org.scalatest.FunSuite {
|
|
127
|
+
test("addition") {
|
|
128
|
+
val sum = 1 + 1
|
|
129
|
+
assert(sum === 2)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
SCALA
|
|
133
|
+
lambda { define('foo').test.invoke }.should_not raise_error
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'should fail when ScalaTest test case fails' do
|
|
137
|
+
write 'src/test/scala/FailingSuite.scala', <<-SCALA
|
|
138
|
+
class FailingSuite extends org.scalatest.FunSuite {
|
|
139
|
+
test("failing") {
|
|
140
|
+
assert(false)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
SCALA
|
|
144
|
+
lambda { define('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/) rescue nil
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'should report failed test names' do
|
|
148
|
+
write 'src/test/scala/FailingSuite.scala', <<-SCALA
|
|
149
|
+
class FailingSuite extends org.scalatest.FunSuite {
|
|
150
|
+
test("failing") {
|
|
151
|
+
assert(false)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
SCALA
|
|
155
|
+
define('foo').test.invoke rescue
|
|
156
|
+
project('foo').test.failed_tests.should include('FailingSuite')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'should report to reports/scalatest/TEST-TestSuiteName.txt' do
|
|
160
|
+
write 'src/test/scala/PassingSuite.scala', <<-SCALA
|
|
161
|
+
class PassingSuite extends org.scalatest.FunSuite {
|
|
162
|
+
test("passing") {
|
|
163
|
+
assert(true)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
SCALA
|
|
167
|
+
define 'foo' do
|
|
168
|
+
test.report_to.should be(file('reports/scalatest'))
|
|
169
|
+
end
|
|
170
|
+
project('foo').test.invoke
|
|
171
|
+
project('foo').file('reports/scalatest/TEST-PassingSuite.txt').should exist
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'should pass properties to Suite' do
|
|
175
|
+
write 'src/test/scala/PropertyTestSuite.scala', <<-SCALA
|
|
176
|
+
import org.scalatest._
|
|
177
|
+
class PropertyTestSuite extends FunSuite {
|
|
178
|
+
var properties = Map[String, Any]()
|
|
179
|
+
test("testProperty") {
|
|
180
|
+
assert(properties("name") === "value")
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
protected override def runTests(testName: Option[String], reporter: Reporter, stopper: Stopper,
|
|
184
|
+
includes: Set[String], excludes: Set[String], properties: Map[String, Any]) {
|
|
185
|
+
this.properties = properties;
|
|
186
|
+
super.runTests(testName, reporter, stopper, includes, excludes, properties)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
SCALA
|
|
190
|
+
define('foo').test.using :properties=>{ 'name'=>'value' }
|
|
191
|
+
project('foo').test.invoke
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it 'should set current directory' do
|
|
195
|
+
mkpath 'baz'
|
|
196
|
+
expected = File.expand_path('baz')
|
|
197
|
+
expected.gsub!('/', '\\') if expected =~ /^[A-Z]:/ # Java returns back slashed paths for windows
|
|
198
|
+
write 'baz/src/test/scala/CurrentDirectoryTestSuite.scala', <<-SCALA
|
|
199
|
+
class CurrentDirectoryTestSuite extends org.scalatest.FunSuite {
|
|
200
|
+
test("testCurrentDirectory") {
|
|
201
|
+
assert("value" === System.getenv("NAME"))
|
|
202
|
+
assert(#{expected.inspect} === new java.io.File(".").getCanonicalPath())
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
SCALA
|
|
206
|
+
define 'bar' do
|
|
207
|
+
define 'baz' do
|
|
208
|
+
test.include 'CurrentDirectoryTest'
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
project('bar:baz').test.invoke
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
end
|
|
215
|
+
|