buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toulm...@apache.org
Subject [1/3] buildr git commit: BUILDR-454: Definition-level parent-child references-by-name fail in 1.4.0 but not in 1.3.5
Date Sun, 14 Aug 2016 06:26:34 GMT
Repository: buildr
Updated Branches:
  refs/heads/master 24724f998 -> 2f1437922


BUILDR-454: Definition-level parent-child references-by-name fail in 1.4.0 but not in 1.3.5


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

Branch: refs/heads/master
Commit: a850d8c98bf32a5f8fe14e274155efdf822dcb45
Parents: 42a016d
Author: Antoine Toulme <antoine@lunar-ocean.com>
Authored: Sat Aug 13 22:44:02 2016 -0700
Committer: Antoine Toulme <antoine@lunar-ocean.com>
Committed: Sat Aug 13 22:44:02 2016 -0700

----------------------------------------------------------------------
 lib/buildr/core/project.rb | 15 ++++++++++++++-
 spec/core/project_spec.rb  | 17 +++++++++++------
 2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/a850d8c9/lib/buildr/core/project.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/core/project.rb b/lib/buildr/core/project.rb
index 1b34eb4..4511ae4 100644
--- a/lib/buildr/core/project.rb
+++ b/lib/buildr/core/project.rb
@@ -220,6 +220,11 @@ module Buildr #:nodoc:
           # Enhance the project using the definition block.
           project.enhance { project.instance_exec project, &block } if block
 
+          # Mark the project as defined
+          project.enhance do |project|
+            project.send :define!
+          end
+
           # Top-level project? Invoke the project definition. Sub-project? We don't invoke
           # the project definiton yet (allow project calls to establish order of evaluation),
           # but must do so before the parent project's definition is done.
@@ -253,7 +258,7 @@ module Buildr #:nodoc:
         end
         project ||= @projects[name] # Not found in scope.
         raise "No such project #{name}" unless project
-        project.invoke unless no_invoke || Buildr.application.current_scope.join(":").to_s
== project.name.to_s
+        project.invoke unless  project.defined? || no_invoke || Buildr.application.current_scope.join(":").to_s
== project.name.to_s
         project
       end
 
@@ -614,7 +619,15 @@ module Buildr #:nodoc:
       @calledback ||= {}
     end
 
+    def defined?
+      @defined
+    end
+
   protected
+    def define!
+      @defined = true
+    end
+    
 
     # :call-seq:
     #   base_dir = dir

http://git-wip-us.apache.org/repos/asf/buildr/blob/a850d8c9/spec/core/project_spec.rb
----------------------------------------------------------------------
diff --git a/spec/core/project_spec.rb b/spec/core/project_spec.rb
index 97bbf01..b9f591a 100644
--- a/spec/core/project_spec.rb
+++ b/spec/core/project_spec.rb
@@ -83,6 +83,16 @@ describe Project do
     Buildr.define('foo') { define('bar') { project('baz:bar') } }
     lambda { project('foo') }.should raise_error(RuntimeError, /Circular dependency/)
   end
+
+  it 'should handle non-circular dependencies' do
+    Buildr.define "root" do
+      define "child" do
+        puts project('root')._('foo.resource')
+      end
+    end
+
+    lambda { project('root') }.should_not raise_error
+  end
 end
 
 describe Project, ' property' do
@@ -533,7 +543,7 @@ describe Buildr, '#project' do
     project('foo:bar').project('baz').should be(project('foo:baz'))
   end
 
-  it 'should fine a project from its parent by proximity' do
+  it 'should find a project from its parent by proximity' do
     define 'foo' do
       define('bar') { define 'baz' }
       define 'baz'
@@ -542,11 +552,6 @@ describe Buildr, '#project' do
     project('foo:bar').project('baz').should be(project('foo:bar:baz'))
   end
 
-  it 'should invoke project before returning it' do
-    define('foo').should_receive(:invoke).once
-    project('foo')
-  end
-
   it 'should fail if called without a project name' do
     lambda { project }.should raise_error(ArgumentError)
   end


Mime
View raw message