2011-06-23 18:11:55 -04:00
|
|
|
require File.expand_path('../helper', __FILE__)
|
2009-10-02 15:07:55 -04:00
|
|
|
|
2011-06-23 18:11:55 -04:00
|
|
|
class TestRakeNameSpace < Rake::TestCase
|
2009-10-02 15:07:55 -04:00
|
|
|
|
|
|
|
class TM
|
|
|
|
include Rake::TaskManager
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_namespace_creation
|
|
|
|
mgr = TM.new
|
|
|
|
ns = Rake::NameSpace.new(mgr, [])
|
2011-06-23 18:11:55 -04:00
|
|
|
refute_nil ns
|
2009-10-02 15:07:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_namespace_lookup
|
|
|
|
mgr = TM.new
|
|
|
|
ns = mgr.in_namespace("n") do
|
|
|
|
mgr.define_task(Rake::Task, "t")
|
|
|
|
end
|
|
|
|
|
2011-06-23 18:11:55 -04:00
|
|
|
refute_nil ns["t"]
|
2009-10-02 15:07:55 -04:00
|
|
|
assert_equal mgr["n:t"], ns["t"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_namespace_reports_tasks_it_owns
|
|
|
|
mgr = TM.new
|
|
|
|
nns = nil
|
|
|
|
ns = mgr.in_namespace("n") do
|
|
|
|
mgr.define_task(Rake::Task, :x)
|
|
|
|
mgr.define_task(Rake::Task, :y)
|
|
|
|
nns = mgr.in_namespace("nn") do
|
|
|
|
mgr.define_task(Rake::Task, :z)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
mgr.in_namespace("m") do
|
|
|
|
mgr.define_task(Rake::Task, :x)
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal ["n:nn:z", "n:x", "n:y"],
|
|
|
|
ns.tasks.map { |tsk| tsk.name }
|
2013-10-11 17:35:01 -04:00
|
|
|
assert_equal ["n:nn:z"], nns.tasks.map { |t| t.name }
|
2009-10-02 15:07:55 -04:00
|
|
|
end
|
2014-07-14 23:07:37 -04:00
|
|
|
|
|
|
|
def test_scope
|
|
|
|
mgr = TM.new
|
|
|
|
|
|
|
|
scope = Rake::LinkedList.new 'b'
|
|
|
|
scope = scope.conj 'a'
|
|
|
|
|
|
|
|
ns = Rake::NameSpace.new mgr, scope
|
|
|
|
|
|
|
|
assert_equal scope, ns.scope
|
|
|
|
|
|
|
|
refute_same scope, ns.scope
|
|
|
|
end
|
|
|
|
|
2009-10-02 15:07:55 -04:00
|
|
|
end
|