You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2015/02/20 00:38:15 UTC

[1/5] buildr git commit: Removing runtime dependency on rspec

Repository: buildr
Updated Branches:
  refs/heads/master 41970b737 -> 877e57b93


Removing runtime dependency on rspec

Addresses https://issues.apache.org/jira/browse/BUILDR-705

Since usage of rspec support in buildr is optional, it should be
listed only as "development dependency" so others can control their rspec
versions independently when not using buildr's rspec support.


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/c1b21a85
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/c1b21a85
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/c1b21a85

Branch: refs/heads/master
Commit: c1b21a85d35444c15448d76e7b5c63dc62d4b3c3
Parents: ad5f857
Author: r6p <r6...@r6p.com>
Authored: Wed Feb 4 11:31:32 2015 -0800
Committer: Peter Donald <pe...@realityforge.org>
Committed: Sat Feb 14 07:32:12 2015 +1100

----------------------------------------------------------------------
 buildr.gemspec | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/c1b21a85/buildr.gemspec
----------------------------------------------------------------------
diff --git a/buildr.gemspec b/buildr.gemspec
index b78133e..0c9f706 100644
--- a/buildr.gemspec
+++ b/buildr.gemspec
@@ -68,10 +68,6 @@ for those one-off tasks, with a language that's a joy to use.
   spec.add_dependency 'rjb',                  '1.5.1' if ($platform.to_s == 'x86-mswin32' || $platform.to_s == 'ruby')
   spec.add_dependency 'atoulme-Antwrap',      '0.7.5'
   spec.add_dependency 'diff-lcs',             '1.2.4'
-  spec.add_dependency 'rspec-expectations',   '2.14.3'
-  spec.add_dependency 'rspec-mocks',          '2.14.3'
-  spec.add_dependency 'rspec-core',           '2.14.5'
-  spec.add_dependency 'rspec',                '2.14.1'
   spec.add_dependency 'xml-simple',           '1.1.2'
   spec.add_dependency 'minitar',              '0.5.4'
   spec.add_dependency 'jruby-openssl',        '~> 0.8.2' if $platform.to_s == 'java'
@@ -87,8 +83,12 @@ for those one-off tasks, with a language that's a joy to use.
     spec.add_development_dependency 'rdoc', '4.0.1'
   end
 
-  spec.add_development_dependency 'rspec-retry', '0.2.1'
-  spec.add_development_dependency 'ci_reporter', '1.9.0'
+  spec.add_development_dependency 'rspec-expectations',   '2.14.3'
+  spec.add_development_dependency 'rspec-mocks',          '2.14.3'
+  spec.add_development_dependency 'rspec-core',           '2.14.5'
+  spec.add_development_dependency 'rspec',                '2.14.1'
+  spec.add_development_dependency 'rspec-retry',          '0.2.1'
+  spec.add_development_dependency 'ci_reporter',          '1.9.0'
   # Ideally we would depend on psych when the platform has >= 1.9.2 support and jruby platform version > 1.6.6
   #spec.add_development_dependency 'psych' if RUBY_VERSION >= '1.9.2'
   spec.add_development_dependency 'pygmentize', '0.0.3'


[2/5] buildr git commit: Prefer single quotes

Posted by do...@apache.org.
Prefer single quotes


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/b359ca40
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/b359ca40
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/b359ca40

Branch: refs/heads/master
Commit: b359ca405f968128fd35cb850f7bcdf5db833bff
Parents: c1b21a8
Author: Peter Donald <pe...@realityforge.org>
Authored: Sat Feb 14 07:54:12 2015 +1100
Committer: Peter Donald <pe...@realityforge.org>
Committed: Sat Feb 14 07:54:12 2015 +1100

----------------------------------------------------------------------
 lib/buildr/core/checks.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/b359ca40/lib/buildr/core/checks.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/core/checks.rb b/lib/buildr/core/checks.rb
index 60e8422..a695fef 100644
--- a/lib/buildr/core/checks.rb
+++ b/lib/buildr/core/checks.rb
@@ -84,7 +84,7 @@ module Buildr #:nodoc:
       def initialize(*args, &block)
         @description = args.pop if String === args.last
         @subject = args.shift
-        raise ArgumentError, "Expecting subject followed by description, and either one is optional. Not quite sure what to do with this list of arguments." unless args.empty?
+        raise ArgumentError, 'Expecting subject followed by description, and either one is optional. Not quite sure what to do with this list of arguments.' unless args.empty?
         @block = block || lambda { |klass| info "Pending: #{description}" }
       end
 
@@ -150,9 +150,9 @@ module Buildr #:nodoc:
           end
         end or fail "Checks failed for project #{project.name} (see errors above)."
       end
-      project.task("package").enhance do |task|
+      project.task('package').enhance do |task|
         # Run all actions before checks.
-        task.enhance { project.task("check").invoke }
+        task.enhance { project.task('check').invoke }
       end
     end
 


[4/5] buildr git commit: Makr the rspec dependency optional, except when actual rspec features used in buildfile.

Posted by do...@apache.org.
Makr the rspec dependency optional, except when actual rspec features used in buildfile.

Update the buildr gemspec so that rspec is no longer a required dependency.
This enables end-users to use a different version of rspec and buildr in
the same project. The rspec version MUST be be compatible with the version
used by Buildr if rspec features are used from within Buildr. Buildr also
issues a warning if the `check` method is called and rspec has not been loaded.
The warning includes directions on how to resolve the issue. Submitted by r6p.


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/10c17635
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/10c17635
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/10c17635

Branch: refs/heads/master
Commit: 10c176350aa836c27ff0a0f690cd3621ab14aec6
Parents: c3c859c
Author: Peter Donald <pe...@realityforge.org>
Authored: Sat Feb 14 20:42:20 2015 +1100
Committer: Peter Donald <pe...@realityforge.org>
Committed: Sat Feb 14 20:42:20 2015 +1100

----------------------------------------------------------------------
 CHANGELOG                      |  6 +++
 lib/buildr.rb                  |  2 +-
 lib/buildr/core/checks.rb      |  1 +
 lib/buildr/java/test_result.rb | 82 ++++++++++++++++++++-----------------
 lib/buildr/rspec_check.rb      | 51 +++++++++++++++++++++++
 5 files changed, 104 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/10c17635/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 851d3f9..c7a382f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,10 @@
 1.4.22 (Pending)
+* Change: Update the buildr gemspec so that rspec is no longer a required dependency.
+          This enables end-users to use a different version of rspec and buildr in
+          the same project. The rspec version MUST be be compatible with the version
+          used by Buildr if rspec features are used from within Buildr. Buildr also
+          issues a warning if the `check` method is called and rspec has not been loaded.
+          The warning includes directions on how to resolve the issue. Submitted by r6p.
 * Fixed:  A long standing bug existed such that if tests failed to compile, and the
           option Buildr.options.test is set to :all then the compilation error would
           not result in a failed build. As many people set the Buildr.options.test to

http://git-wip-us.apache.org/repos/asf/buildr/blob/10c17635/lib/buildr.rb
----------------------------------------------------------------------
diff --git a/lib/buildr.rb b/lib/buildr.rb
index 669e386..b41a0c1 100644
--- a/lib/buildr.rb
+++ b/lib/buildr.rb
@@ -28,7 +28,6 @@ autoload :YAML, 'yaml'
 autoload :REXML, 'rexml/document'
 autoload :XmlSimple, 'xmlsimple'
 autoload :Builder, 'builder' # A different kind of buildr, one we use to create XML.
-autoload :RSpec, 'rspec'
 require 'erb'
 require 'find'
 require 'uri'
@@ -37,6 +36,7 @@ require 'fileutils'
 require 'orderedhash'
 require 'securerandom'
 
+require 'buildr/rspec_check'
 require 'buildr/core/util'
 require 'buildr/core/console'
 require 'buildr/core/common'

http://git-wip-us.apache.org/repos/asf/buildr/blob/10c17635/lib/buildr/core/checks.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/core/checks.rb b/lib/buildr/core/checks.rb
index a695fef..78ebc6f 100644
--- a/lib/buildr/core/checks.rb
+++ b/lib/buildr/core/checks.rb
@@ -186,6 +186,7 @@ module Buildr #:nodoc:
     # During development you can write placeholder expectations by omitting the block. This will simply report
     # the expectation as pending.
     def check(*args, &block)
+      Buildr.ensure_rspec('check() method invoked in buildfile')
       expectations << Checks::Expectation.new(*args, &block)
     end
 

http://git-wip-us.apache.org/repos/asf/buildr/blob/10c17635/lib/buildr/java/test_result.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/java/test_result.rb b/lib/buildr/java/test_result.rb
index 3a8b608..979142c 100644
--- a/lib/buildr/java/test_result.rb
+++ b/lib/buildr/java/test_result.rb
@@ -15,7 +15,11 @@
 
 # It is necessary to require these files here as the bdd plugin directly includes this file
 require 'yaml'
-require 'rspec/core/formatters/base_formatter'
+begin
+  require 'rspec/core/formatters/base_formatter'
+rescue LoadError
+  # If Rspec is not present then assume we do no need Yaml formatter
+end
 
 module Buildr #:nodoc:
   module TestFramework #:nodoc:
@@ -52,49 +56,53 @@ module Buildr #:nodoc:
         @failed, @succeeded = [], []
       end
 
-      # An Rspec formatter used by buildr
-      class YamlFormatter  < ::RSpec::Core::Formatters::BaseFormatter
-        attr_reader :result
+      if Buildr.rspec_present?
+        require 'rspec/core/formatters/base_formatter'
 
-        def initialize(output)
-          super(output)
-          @result = Hash.new
-          @result[:succeeded] = []
-          @result[:failed] = []
-        end
+        # An Rspec formatter used by buildr
+        class YamlFormatter  < ::RSpec::Core::Formatters::BaseFormatter
+          attr_reader :result
 
-        def example_passed(example)
-          super(example)
-          result.succeeded << example_name(example)
-        end
+          def initialize(output)
+            super(output)
+            @result = Hash.new
+            @result[:succeeded] = []
+            @result[:failed] = []
+          end
 
-        def example_pending(example)
-          super(example)
-          result.succeeded << example_name(example)
-        end
+          def example_passed(example)
+            super(example)
+            result.succeeded << example_name(example)
+          end
 
-        def example_failed(example)
-          super(example)
-          result.failed << example_name(example)
-        end
+          def example_pending(example)
+            super(example)
+            result.succeeded << example_name(example)
+          end
 
-        def start(example_count)
-          super(example_count)
-          @result = TestResult.new
-        end
+          def example_failed(example)
+            super(example)
+            result.failed << example_name(example)
+          end
 
-        def close
-          super
-          result.succeeded = result.succeeded - result.failed
-          output.puts YAML.dump(result)
-        end
+          def start(example_count)
+            super(example_count)
+            @result = TestResult.new
+          end
 
-      private
-        def example_name(example)
-          example.file_path
-        end
-      end # YamlFormatter
+          def close
+            super
+            result.succeeded = result.succeeded - result.failed
+            output.puts YAML.dump(result)
+          end
+
+        private
+          def example_name(example)
+            example.file_path
+          end
+        end # YamlFormatter
 
-    end # TestResult
+      end # TestResult
+    end
   end
 end

http://git-wip-us.apache.org/repos/asf/buildr/blob/10c17635/lib/buildr/rspec_check.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/rspec_check.rb b/lib/buildr/rspec_check.rb
new file mode 100644
index 0000000..7b178b8
--- /dev/null
+++ b/lib/buildr/rspec_check.rb
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+module Buildr #:nodoc:
+
+  @@rspec_checked = false
+
+  def self.rspec_present?
+    unless @@rspec_checked
+      begin
+        require 'rspec'
+      rescue LoadError
+        # If Rspec is not present then that is ok
+      end
+      @@rspec_checked = true
+    end
+
+    $LOADED_FEATURES.any?{|f| f=~ /[\\\/]rspec\.rb$/ }
+  end
+
+  def self.ensure_rspec(context)
+    unless rspec_present?
+      # Has the rspec dependency been loaded?
+      message =
+        "#{context} but RSpec has not been loaded.\n" +
+          "\n" +
+          "Buildr prior to version 1.4.22, included rspec as a dependency but as\n" +
+          "of version 1.4.22, it is expected users manually add RSpec to their\n" +
+          "Gemfile. The following lines should be added to restore the version\n" +
+          "of rspec included in 1.4.22:\n" +
+          "\n" +
+          "gem 'rspec-expectations',   '= 2.14.3'\n" +
+          "gem 'rspec-mocks',          '= 2.14.3'\n" +
+          "gem 'rspec-core',           '= 2.14.5'\n" +
+          "gem 'rspec',                '= 2.14.1'\n"
+      fail message
+    end
+  end
+end


[3/5] buildr git commit: Make sure the spec helpers load the rspec dependency even though it is marked as a developer dependency

Posted by do...@apache.org.
Make sure the spec helpers load the rspec dependency even though it is marked as a developer dependency


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/c3c859cb
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/c3c859cb
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/c3c859cb

Branch: refs/heads/master
Commit: c3c859cb6c12ca0dd42ff7e5e8de1217dccb524d
Parents: b359ca4
Author: Peter Donald <pe...@realityforge.org>
Authored: Sat Feb 14 20:30:46 2015 +1100
Committer: Peter Donald <pe...@realityforge.org>
Committed: Sat Feb 14 20:30:46 2015 +1100

----------------------------------------------------------------------
 spec/spec_helpers.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/c3c859cb/spec/spec_helpers.rb
----------------------------------------------------------------------
diff --git a/spec/spec_helpers.rb b/spec/spec_helpers.rb
index abc8243..5ff98d9 100644
--- a/spec/spec_helpers.rb
+++ b/spec/spec_helpers.rb
@@ -23,7 +23,9 @@ unless defined?(SpecHelpers)
   # For testing we use the gem requirements specified on the buildr.gemspec
   spec = Gem::Specification.load(File.expand_path('../buildr.gemspec', File.dirname(__FILE__)))
   # Dependency.version_requirements deprecated in rubygems 1.3.6
-  spec.dependencies.select {|dep| dep.type == :runtime }.each { |dep| gem dep.name, (dep.respond_to?(:requirement) ? dep.requirement.to_s : dep.version_requirements.to_s) }
+  spec.dependencies.
+    select {|dep| dep.type == :runtime || (dep.type == :development && dep.name.to_s =~ /^rspec.*/) }.
+    each { |dep| gem dep.name, (dep.respond_to?(:requirement) ? dep.requirement.to_s : dep.version_requirements.to_s) }
 
   # Make sure to load from these paths first, we don't want to load any
   # code from Gem library.


[5/5] buildr git commit: Merge branch 'BUILDR-705'

Posted by do...@apache.org.
Merge branch 'BUILDR-705'


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/877e57b9
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/877e57b9
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/877e57b9

Branch: refs/heads/master
Commit: 877e57b938b6bb820448c56f2ec81f0f830d40f0
Parents: 41970b7 10c1763
Author: Peter Donald <pe...@realityforge.org>
Authored: Fri Feb 20 10:38:00 2015 +1100
Committer: Peter Donald <pe...@realityforge.org>
Committed: Fri Feb 20 10:38:00 2015 +1100

----------------------------------------------------------------------
 CHANGELOG                      |  6 +++
 buildr.gemspec                 | 12 +++---
 lib/buildr.rb                  |  2 +-
 lib/buildr/core/checks.rb      |  7 ++--
 lib/buildr/java/test_result.rb | 82 ++++++++++++++++++++-----------------
 lib/buildr/rspec_check.rb      | 51 +++++++++++++++++++++++
 spec/spec_helpers.rb           |  4 +-
 7 files changed, 116 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/877e57b9/CHANGELOG
----------------------------------------------------------------------