buildr 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +76 -0
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +20 -37
- data/_buildr +3 -12
- data/{doc/print.toc.yaml → _jbuildr} +14 -14
- data/addon/buildr/cobertura.rb +5 -219
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +5 -221
- data/addon/buildr/nailgun.rb +93 -689
- data/bin/buildr +0 -9
- data/buildr.buildfile +4 -4
- data/buildr.gemspec +27 -21
- data/doc/_layouts/default.html +82 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
- data/doc/{pages/building.textile → building.textile} +89 -47
- data/doc/{pages/contributing.textile → contributing.textile} +53 -45
- data/doc/css/default.css +6 -5
- data/doc/css/print.css +17 -24
- data/doc/css/syntax.css +7 -36
- data/doc/download.textile +78 -0
- data/doc/{pages/extending.textile → extending.textile} +45 -24
- data/doc/{pages/getting_started.textile → getting_started.textile} +146 -88
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/note.png +0 -0
- data/doc/index.textile +47 -0
- data/doc/{pages/languages.textile → languages.textile} +108 -54
- data/doc/mailing_lists.textile +25 -0
- data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
- data/doc/{pages/packaging.textile → packaging.textile} +181 -96
- data/doc/preface.textile +28 -0
- data/doc/{pages/projects.textile → projects.textile} +55 -40
- data/doc/scripts/buildr-git.rb +364 -264
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +2 -2
- data/doc/scripts/install-linux.sh +6 -6
- data/doc/scripts/install-osx.sh +2 -2
- data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
- data/doc/{pages/testing.textile → testing.textile} +77 -41
- data/lib/buildr.rb +5 -5
- data/lib/buildr/core.rb +2 -0
- data/lib/buildr/core/application.rb +321 -151
- data/lib/buildr/core/build.rb +298 -167
- data/lib/buildr/core/checks.rb +4 -132
- data/lib/buildr/core/common.rb +1 -5
- data/lib/buildr/core/compile.rb +3 -9
- data/lib/buildr/core/environment.rb +12 -3
- data/lib/buildr/core/filter.rb +20 -18
- data/lib/buildr/core/generate.rb +36 -36
- data/lib/buildr/core/help.rb +2 -1
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +7 -34
- data/lib/buildr/core/test.rb +12 -6
- data/lib/buildr/core/transports.rb +13 -11
- data/lib/buildr/core/util.rb +14 -23
- data/lib/buildr/groovy/bdd.rb +3 -2
- data/lib/buildr/groovy/compiler.rb +1 -1
- data/lib/buildr/ide/eclipse.rb +31 -21
- data/lib/buildr/ide/idea.rb +3 -2
- data/lib/buildr/ide/idea7x.rb +6 -4
- data/lib/buildr/java/ant.rb +3 -1
- data/lib/buildr/java/bdd.rb +9 -7
- data/lib/buildr/java/cobertura.rb +243 -0
- data/lib/buildr/java/compiler.rb +5 -4
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/packaging.rb +11 -8
- data/lib/buildr/java/pom.rb +0 -4
- data/lib/buildr/java/rjb.rb +1 -1
- data/lib/buildr/java/test_result.rb +5 -7
- data/lib/buildr/java/tests.rb +17 -11
- data/lib/buildr/packaging.rb +5 -2
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +48 -29
- data/lib/buildr/packaging/artifact_namespace.rb +6 -6
- data/lib/buildr/packaging/gems.rb +4 -4
- data/lib/buildr/packaging/package.rb +3 -2
- data/lib/buildr/packaging/tar.rb +85 -3
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +24 -682
- data/lib/buildr/packaging/ziptask.rb +313 -0
- data/lib/buildr/scala.rb +5 -0
- data/lib/buildr/scala/bdd.rb +100 -0
- data/lib/buildr/scala/compiler.rb +45 -4
- data/lib/buildr/scala/tests.rb +12 -59
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +58 -68
- data/rakelib/jekylltask.rb +110 -0
- data/rakelib/package.rake +35 -37
- data/rakelib/release.rake +119 -35
- data/rakelib/rspec.rake +29 -39
- data/rakelib/setup.rake +21 -59
- data/rakelib/stage.rake +184 -26
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +32 -25
- data/spec/core/build_spec.rb +336 -126
- data/spec/core/checks_spec.rb +292 -310
- data/spec/core/common_spec.rb +8 -2
- data/spec/core/compile_spec.rb +17 -1
- data/spec/core/generate_spec.rb +3 -3
- data/spec/core/project_spec.rb +18 -10
- data/spec/core/test_spec.rb +8 -1
- data/spec/core/transport_spec.rb +40 -3
- data/spec/core/util_spec.rb +67 -0
- data/spec/ide/eclipse_spec.rb +96 -28
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant.rb +5 -0
- data/spec/java/bdd_spec.rb +12 -3
- data/spec/{addon → java}/cobertura_spec.rb +6 -6
- data/spec/{addon → java}/emma_spec.rb +5 -6
- data/spec/java/java_spec.rb +12 -2
- data/spec/java/packaging_spec.rb +31 -2
- data/spec/{addon → java}/test_coverage_spec.rb +3 -3
- data/spec/java/tests_spec.rb +5 -0
- data/spec/packaging/archive_spec.rb +11 -1
- data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
- data/spec/packaging/artifact_spec.rb +44 -3
- data/spec/packaging/packaging_spec.rb +1 -1
- data/spec/sandbox.rb +17 -14
- data/spec/scala/bdd_spec.rb +150 -0
- data/spec/scala/compiler_spec.rb +27 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +78 -33
- data/spec/spec_helpers.rb +29 -5
- data/spec/version_requirement_spec.rb +6 -0
- metadata +175 -171
- data/DISCLAIMER +0 -7
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/pages/download.textile +0 -51
- data/doc/pages/index.textile +0 -42
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/git-svn-authors +0 -16
- data/lib/buildr/core/application_cli.rb +0 -139
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/rubyforge.rake +0 -53
- data/rakelib/scm.rake +0 -49
@@ -0,0 +1,150 @@
|
|
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
|
+
describe Buildr::Scala::Specs do
|
20
|
+
it 'should be the default when tests in src/spec/scala' do
|
21
|
+
write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
|
22
|
+
package com.example
|
23
|
+
object MySpecs extends org.specs.Specification {
|
24
|
+
"it" should {
|
25
|
+
"add" in {
|
26
|
+
val sum = 1 + 1
|
27
|
+
sum mustEqual 2
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
SCALA
|
32
|
+
define 'foo'
|
33
|
+
project('foo').test.framework.should eql(:specs)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should include Specs dependencies' do
|
37
|
+
define('foo') { test.using(:specs) }
|
38
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::Specs.dependencies))
|
39
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::Specs.dependencies))
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should include ScalaCheck dependencies' do
|
43
|
+
define('foo') { test.using(:specs) }
|
44
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::Check.dependencies))
|
45
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::Check.dependencies))
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should include JMock dependencies' do
|
49
|
+
define('foo') { test.using(:scalatest) }
|
50
|
+
project('foo').test.compile.dependencies.should include(*artifacts(JMock.dependencies))
|
51
|
+
project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should include public classes extending org.specs.Specification' do
|
55
|
+
write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
|
56
|
+
package com.example
|
57
|
+
object MySpecs extends org.specs.Specification {
|
58
|
+
"it" should {
|
59
|
+
"add" in {
|
60
|
+
val sum = 1 + 1
|
61
|
+
sum mustEqual 2
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
SCALA
|
66
|
+
define('foo').test.invoke
|
67
|
+
project('foo').test.tests.should include('com.example.MySpecs')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should pass when spec passes' do
|
71
|
+
write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
|
72
|
+
object PassingSpecs extends org.specs.Specification {
|
73
|
+
"it" should {
|
74
|
+
"add" in {
|
75
|
+
val sum = 1 + 1
|
76
|
+
sum mustEqual 2
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
SCALA
|
81
|
+
lambda { define('foo').test.invoke }.should_not raise_error
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should fail when ScalaTest test case fails' do
|
85
|
+
write 'src/spec/scala/FailingSpecs.scala', <<-SCALA
|
86
|
+
object FailingSpecs extends org.specs.Specification {
|
87
|
+
"it" should {
|
88
|
+
"add" in {
|
89
|
+
val sum = 1 + 1
|
90
|
+
sum mustEqual 42
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
SCALA
|
95
|
+
lambda { define('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/) rescue nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should report failed test names' do
|
99
|
+
write 'src/spec/scala/FailingSpecs.scala', <<-SCALA
|
100
|
+
object FailingSpecs extends org.specs.Specification {
|
101
|
+
"it" should {
|
102
|
+
"add" in {
|
103
|
+
val sum = 1 + 1
|
104
|
+
sum mustEqual 42
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
SCALA
|
109
|
+
define('foo').test.invoke rescue
|
110
|
+
project('foo').test.failed_tests.should include('FailingSpecs')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should compile and run specifications with "Specs" suffix' do
|
114
|
+
write 'src/spec/scala/HelloWorldSpecs.scala', <<-SCALA
|
115
|
+
import org.specs._
|
116
|
+
|
117
|
+
object HelloWorldSpecs extends Specification {
|
118
|
+
"'hello world' has 11 characters" in {
|
119
|
+
"hello world".size must beEqualTo(11)
|
120
|
+
}
|
121
|
+
"'hello world' matches 'h.* w.*'" in {
|
122
|
+
"hello world" must beMatching("h.* w.*")
|
123
|
+
}
|
124
|
+
}
|
125
|
+
SCALA
|
126
|
+
define('foo')
|
127
|
+
project('foo').test.invoke
|
128
|
+
project('foo').test.passed_tests.should include('HelloWorldSpecs')
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
it 'should fail if specifications fail' do
|
133
|
+
write 'src/spec/scala/StringSpecs.scala', <<-SCALA
|
134
|
+
import org.specs._
|
135
|
+
import org.specs.runner._
|
136
|
+
|
137
|
+
object StringSpecs extends Specification {
|
138
|
+
"empty string" should {
|
139
|
+
"have a zero length" in {
|
140
|
+
("".length) mustEqual(1)
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
SCALA
|
145
|
+
define('foo')
|
146
|
+
project('foo').test.invoke rescue
|
147
|
+
project('foo').test.failed_tests.should include('StringSpecs')
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
data/spec/scala/compiler_spec.rb
CHANGED
@@ -80,6 +80,33 @@ describe 'scalac compiler' do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
it 'should compile scala class depending on java class in same project' do
|
84
|
+
write 'src/main/java/com/example/Foo.java', 'package com.example; public class Foo {}'
|
85
|
+
write 'src/main/scala/com/example/Bar.scala', 'package com.example; class Bar extends Foo'
|
86
|
+
define 'test1', :version=>'1.0' do
|
87
|
+
package(:jar)
|
88
|
+
end
|
89
|
+
task('test1:package').invoke
|
90
|
+
file('target/test1-1.0.jar').should exist
|
91
|
+
Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
|
92
|
+
zip.file.exist?('com/example/Foo.class').should be_true
|
93
|
+
zip.file.exist?('com/example/Bar.class').should be_true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should compile java class depending on scala class in same project' do
|
98
|
+
write 'src/main/scala/com/example/Foo.scala', 'package com.example; class Foo'
|
99
|
+
write 'src/main/java/com/example/Bar.java', 'package com.example; public class Bar extends Foo {}'
|
100
|
+
define 'test1', :version=>'1.0' do
|
101
|
+
package(:jar)
|
102
|
+
end
|
103
|
+
task('test1:package').invoke
|
104
|
+
file('target/test1-1.0.jar').should exist
|
105
|
+
Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
|
106
|
+
zip.file.exist?('com/example/Foo.class').should be_true
|
107
|
+
zip.file.exist?('com/example/Bar.class').should be_true
|
108
|
+
end
|
109
|
+
end
|
83
110
|
end
|
84
111
|
|
85
112
|
|
data/spec/scala/scala.rb
ADDED
@@ -0,0 +1,38 @@
|
|
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
|
+
describe 'scala' do
|
20
|
+
# Specific version of Scala required for specs
|
21
|
+
required_version = '2.7.3'
|
22
|
+
scala_version_str = "version 2.7.3.final"
|
23
|
+
|
24
|
+
it 'should automatically add the remote scala-tools.org repository' do
|
25
|
+
# NOTE: the sandbox environment clears "repositories.remote" so we can't
|
26
|
+
# test for this spec right now.
|
27
|
+
#
|
28
|
+
# repositories.remote.should include('http://scala-tools.org/repo-releases')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "specifications require Scala #{required_version}" do
|
32
|
+
Scala.version.should eql(required_version)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should provide the Scala version string" do
|
36
|
+
Scala.version_str.should eql(scala_version_str)
|
37
|
+
end
|
38
|
+
end
|
data/spec/scala/tests_spec.rb
CHANGED
@@ -17,9 +17,6 @@
|
|
17
17
|
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
18
|
|
19
19
|
# TODO's
|
20
|
-
# -test w/ Specs
|
21
|
-
# -test w/ ScalaCheck
|
22
|
-
# -failing test
|
23
20
|
# -test passing System props
|
24
21
|
# -test passing ENV variables
|
25
22
|
# -test exclude group
|
@@ -43,13 +40,6 @@ describe Buildr::Scala::ScalaTest do
|
|
43
40
|
project('foo').test.framework.should eql(:scalatest)
|
44
41
|
end
|
45
42
|
|
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
43
|
it 'should include Scalatest dependencies' do
|
54
44
|
define('foo') { test.using(:scalatest) }
|
55
45
|
project('foo').test.compile.dependencies.should include(*artifacts(Scala::ScalaTest.dependencies))
|
@@ -61,17 +51,31 @@ describe Buildr::Scala::ScalaTest do
|
|
61
51
|
project('foo').test.compile.dependencies.should include(*artifacts(JMock.dependencies))
|
62
52
|
project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
|
63
53
|
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
54
|
|
71
55
|
it 'should include ScalaCheck dependencies' do
|
72
56
|
define('foo') { test.using(:scalatest) }
|
73
|
-
project('foo').test.compile.dependencies.should include(*artifacts(Scala::
|
74
|
-
project('foo').test.dependencies.should include(*artifacts(Scala::
|
57
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::Check.dependencies))
|
58
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::Check.dependencies))
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should set current directory' do
|
62
|
+
mkpath 'baz'
|
63
|
+
expected = File.expand_path('baz')
|
64
|
+
expected.gsub!('/', '\\') if expected =~ /^[A-Z]:/ # Java returns back slashed paths for windows
|
65
|
+
write 'baz/src/test/scala/CurrentDirectoryTestSuite.scala', <<-SCALA
|
66
|
+
class CurrentDirectoryTestSuite extends org.scalatest.FunSuite {
|
67
|
+
test("testCurrentDirectory") {
|
68
|
+
assert("value" === System.getenv("NAME"))
|
69
|
+
assert(#{expected.inspect} === new java.io.File(".").getCanonicalPath())
|
70
|
+
}
|
71
|
+
}
|
72
|
+
SCALA
|
73
|
+
define 'bar' do
|
74
|
+
define 'baz' do
|
75
|
+
test.include 'CurrentDirectoryTest'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
project('bar:baz').test.invoke
|
75
79
|
end
|
76
80
|
|
77
81
|
it 'should include public classes extending org.scalatest.FunSuite' do
|
@@ -191,24 +195,65 @@ describe Buildr::Scala::ScalaTest do
|
|
191
195
|
project('foo').test.invoke
|
192
196
|
end
|
193
197
|
|
194
|
-
it 'should
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
198
|
+
it 'should run with ScalaCheck automatic test case generation' do
|
199
|
+
write 'src/test/scala/MySuite.scala', <<-SCALA
|
200
|
+
import org.scalatest.prop.PropSuite
|
201
|
+
import org.scalacheck.Arbitrary._
|
202
|
+
import org.scalacheck.Prop._
|
203
|
+
|
204
|
+
class MySuite extends PropSuite {
|
205
|
+
|
206
|
+
test("list concatenation") {
|
207
|
+
val x = List(1, 2, 3)
|
208
|
+
val y = List(4, 5, 6)
|
209
|
+
assert(x ::: y === List(1, 2, 3, 4, 5, 6))
|
210
|
+
check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size)
|
203
211
|
}
|
212
|
+
|
213
|
+
test(
|
214
|
+
"list concatenation using a test method",
|
215
|
+
(a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size
|
216
|
+
)
|
204
217
|
}
|
205
218
|
SCALA
|
206
|
-
define
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
219
|
+
define('foo')
|
220
|
+
project('foo').test.invoke
|
221
|
+
project('foo').test.passed_tests.should include('MySuite')
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should fail if ScalaCheck test case fails' do
|
225
|
+
write 'src/test/scala/StringSuite.scala', <<-SCALA
|
226
|
+
import org.scalatest.prop.PropSuite
|
227
|
+
import org.scalacheck.Arbitrary._
|
228
|
+
import org.scalacheck.Prop._
|
229
|
+
|
230
|
+
class StringSuite extends PropSuite {
|
231
|
+
test("startsWith") {
|
232
|
+
check( (a: String, b: String) => (a+b).startsWith(a) )
|
233
|
+
}
|
234
|
+
|
235
|
+
test("endsWith") {
|
236
|
+
check( (a: String, b: String) => (a+b).endsWith(b) )
|
237
|
+
}
|
238
|
+
|
239
|
+
// Is this really always true?
|
240
|
+
test("concat") {
|
241
|
+
check( (a: String, b: String) => (a+b).length > a.length && (a+b).length > b.length )
|
242
|
+
}
|
243
|
+
|
244
|
+
test("substring2") {
|
245
|
+
check( (a: String, b: String) => (a+b).substring(a.length) == b )
|
246
|
+
}
|
247
|
+
|
248
|
+
test("substring3") {
|
249
|
+
check( (a: String, b: String, c: String) =>
|
250
|
+
(a+b+c).substring(a.length, a.length+b.length) == b )
|
251
|
+
}
|
252
|
+
}
|
253
|
+
SCALA
|
254
|
+
define('foo')
|
255
|
+
project('foo').test.invoke rescue
|
256
|
+
project('foo').test.failed_tests.should include('StringSuite')
|
212
257
|
end
|
213
258
|
|
214
259
|
end
|
data/spec/spec_helpers.rb
CHANGED
@@ -19,7 +19,23 @@
|
|
19
19
|
unless defined?(SpecHelpers)
|
20
20
|
|
21
21
|
require 'rubygems'
|
22
|
-
|
22
|
+
|
23
|
+
# For testing we use the gem requirements specified on the buildr.gemspec
|
24
|
+
spec = Gem::Specification.load(File.expand_path('../buildr.gemspec', File.dirname(__FILE__)))
|
25
|
+
spec.dependencies.each { |dep| gem dep.name, dep.version_requirements.to_s }
|
26
|
+
|
27
|
+
# Make sure to load from these paths first, we don't want to load any
|
28
|
+
# code from Gem library.
|
29
|
+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__)),
|
30
|
+
File.expand_path('../addon', File.dirname(__FILE__))
|
31
|
+
|
32
|
+
# Buildr uses autoload extensively, but autoload when running specs creates
|
33
|
+
# a problem -- we sandbox $LOADED_FEATURES, so we endup autoloading the same
|
34
|
+
# module twice. This turns autoload into a require, which is not the right
|
35
|
+
# thing, but will do for now.
|
36
|
+
def autoload(symbol, path)
|
37
|
+
require path
|
38
|
+
end
|
23
39
|
require 'buildr'
|
24
40
|
|
25
41
|
require File.expand_path('sandbox', File.dirname(__FILE__))
|
@@ -28,11 +44,12 @@ unless defined?(SpecHelpers)
|
|
28
44
|
|
29
45
|
include Checks::Matchers
|
30
46
|
|
31
|
-
[:info, :warn, :error].each do |severity|
|
47
|
+
[:info, :warn, :error, :puts].each do |severity|
|
32
48
|
::Object.class_eval do
|
33
|
-
define_method severity do |
|
49
|
+
define_method severity do |*args|
|
34
50
|
$messages ||= {}
|
35
|
-
|
51
|
+
$messages[severity] ||= []
|
52
|
+
$messages[severity].push(*args)
|
36
53
|
end
|
37
54
|
end
|
38
55
|
end
|
@@ -74,7 +91,7 @@ unless defined?(SpecHelpers)
|
|
74
91
|
MessageWithSeverityMatcher.new :info, message
|
75
92
|
end
|
76
93
|
|
77
|
-
#
|
94
|
+
# Test if a warning was shown. You can use a string or regular expression.
|
78
95
|
#
|
79
96
|
# For example:
|
80
97
|
# lambda { warn 'ze test' }.should show_warning(/ze test/)
|
@@ -90,6 +107,13 @@ unless defined?(SpecHelpers)
|
|
90
107
|
MessageWithSeverityMatcher.new :error, message
|
91
108
|
end
|
92
109
|
|
110
|
+
# Test if any message was shown (puts). You can use a string or regular expression.
|
111
|
+
#
|
112
|
+
# For example:
|
113
|
+
# lambda { puts 'ze test' }.should show(/ze test/)
|
114
|
+
def show(message)
|
115
|
+
MessageWithSeverityMatcher.new :puts, message
|
116
|
+
end
|
93
117
|
|
94
118
|
class ::Rake::Task
|
95
119
|
alias :execute_without_a_record :execute
|
@@ -44,6 +44,11 @@ describe Buildr::VersionRequirement, '.create' do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
=begin
|
48
|
+
# TODO: Fix this.
|
49
|
+
# 1. Can't use should_satisfy, this breaks under RSpec 1.2
|
50
|
+
# 2. These should_satisfy calls are not proper specs since the subject is
|
51
|
+
# the satistifed_by? method. satisfied_by should satisfy???
|
47
52
|
describe Buildr::VersionRequirement, '#satisfied_by?' do
|
48
53
|
def should_satisfy(str, valids = [], invalids = [])
|
49
54
|
req = Buildr::VersionRequirement.create(str)
|
@@ -102,6 +107,7 @@ describe Buildr::VersionRequirement, '#satisfied_by?' do
|
|
102
107
|
should_satisfy '!(2 | 3) | 1', %w(1), %w(2 3)
|
103
108
|
end
|
104
109
|
end
|
110
|
+
=end
|
105
111
|
|
106
112
|
describe Buildr::VersionRequirement, '#default' do
|
107
113
|
it 'should return nil if missing default requirement' do
|