add Environment#expand_varref()

This commit is contained in:
Josh Holtrop 2014-01-02 11:49:08 -05:00
parent e3aadc562f
commit 5ff555cf6a
2 changed files with 19 additions and 0 deletions

View File

@ -185,6 +185,11 @@ module Rscons
@varset.merge(extra_vars).expand_varref(command_template)
end
# Expand a construction variable reference (String or Array)
def expand_varref(varref)
@varset.expand_varref(varref)
end
# Execute a builder command
# @param short_desc [String] Message to print if the Environment's echo
# mode is set to :short

View File

@ -199,6 +199,20 @@ module Rscons
end
end
describe "#expand_varref" do
it "returns the fully expanded variable reference" do
env = Environment.new
env["path"] = ["dir1", "dir2"]
env["flags"] = ["-x", "-y", "${specialflag}"]
env["specialflag"] = "-z"
env.expand_varref(["-p${path}", "${flags}"]).should == ["-pdir1", "-pdir2", "-x", "-y", "-z"]
env.expand_varref("foo").should == "foo"
expect {env.expand_varref("${foo}")}.to raise_error /expand.a.variable.reference/
env.expand_varref("${specialflag}").should == "-z"
env.expand_varref("${path}").should == ["dir1", "dir2"]
end
end
describe "#execute" do
context "with echo: :short" do
context "with no errors" do