use new rspec expect syntax
This commit is contained in:
1 parent
7b13d51d23
commit
42597b2dac
4 files changed
+163
-163
No files matched your search
+23
-23
@@ -20,7 +20,7 @@ module Rscons
|
||||
$stderr.should_receive(:puts).with(/Warning:.*was.corrupt/)
|
||||
c = Cache.instance
|
||||
c.send(:initialize!)
|
||||
c.instance_variable_get(:@cache).is_a?(Hash).should be_true
|
||||
expect(c.instance_variable_get(:@cache).is_a?(Hash)).to be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -40,7 +40,7 @@ module Rscons
|
||||
fh.should_receive(:puts)
|
||||
File.should_receive(:open).and_yield(fh)
|
||||
build_from(cache).write
|
||||
cache["version"].should == Rscons::VERSION
|
||||
expect(cache["version"]).to eq Rscons::VERSION
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,12 +52,12 @@ module Rscons
|
||||
|
||||
it "returns false when target file does not exist" do
|
||||
File.should_receive(:exists?).with("target").and_return(false)
|
||||
build_from({}).up_to_date?("target", "command", [], empty_env).should be_false
|
||||
expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when target is not registered in the cache" do
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
build_from({}).up_to_date?("target", "command", [], empty_env).should be_false
|
||||
expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when the target's checksum does not match" do
|
||||
@@ -65,7 +65,7 @@ module Rscons
|
||||
cache = build_from(_cache)
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
cache.should_receive(:calculate_checksum).with("target").and_return("def")
|
||||
cache.up_to_date?("target", "command", [], empty_env).should be_false
|
||||
expect(cache.up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when the build command has changed" do
|
||||
@@ -73,7 +73,7 @@ module Rscons
|
||||
cache = build_from(_cache)
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
cache.should_receive(:calculate_checksum).with("target").and_return("abc")
|
||||
cache.up_to_date?("target", "command", [], empty_env).should be_false
|
||||
expect(cache.up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when there is a new dependency" do
|
||||
@@ -83,7 +83,7 @@ module Rscons
|
||||
cache = build_from(_cache)
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
cache.should_receive(:calculate_checksum).with("target").and_return("abc")
|
||||
cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env).should be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when a dependency's checksum has changed" do
|
||||
@@ -101,7 +101,7 @@ module Rscons
|
||||
cache.should_receive(:calculate_checksum).with("target").and_return("abc")
|
||||
cache.should_receive(:calculate_checksum).with("dep.1").and_return("dep.1.chk")
|
||||
cache.should_receive(:calculate_checksum).with("dep.2").and_return("dep.2.changed")
|
||||
cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env).should be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false with strict_deps=true when cache has an extra dependency" do
|
||||
@@ -117,7 +117,7 @@ module Rscons
|
||||
cache = build_from(_cache)
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
cache.should_receive(:calculate_checksum).with("target").and_return("abc")
|
||||
cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env, strict_deps: true).should be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env, strict_deps: true)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when there is a new user dependency" do
|
||||
@@ -130,7 +130,7 @@ module Rscons
|
||||
env.should_receive(:get_user_deps).with("target").and_return(["file.ld"])
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
cache.should_receive(:calculate_checksum).with("target").and_return("abc")
|
||||
cache.up_to_date?("target", "command", ["dep.1"], env).should be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1"], env)).to be_false
|
||||
end
|
||||
|
||||
it "returns false when a user dependency checksum has changed" do
|
||||
@@ -153,7 +153,7 @@ module Rscons
|
||||
cache.should_receive(:calculate_checksum).with("dep.2").and_return("dep.2.chk")
|
||||
cache.should_receive(:calculate_checksum).with("extra.dep").and_return("extra.dep.chk")
|
||||
cache.should_receive(:calculate_checksum).with("user.dep").and_return("INCORRECT")
|
||||
cache.up_to_date?("target", "command", ["dep.1", "dep.2"], env).should be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], env)).to be_false
|
||||
end
|
||||
|
||||
it "returns true when no condition for false is met" do
|
||||
@@ -172,7 +172,7 @@ module Rscons
|
||||
cache.should_receive(:calculate_checksum).with("dep.1").and_return("dep.1.chk")
|
||||
cache.should_receive(:calculate_checksum).with("dep.2").and_return("dep.2.chk")
|
||||
cache.should_receive(:calculate_checksum).with("extra.dep").and_return("extra.dep.chk")
|
||||
cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env).should be_true
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -189,13 +189,13 @@ module Rscons
|
||||
cache.register_build("the target", "the command", ["dep 1", "dep 2"], env)
|
||||
cached_target = cache.instance_variable_get(:@cache)["targets"]["the target"]
|
||||
cached_target.should_not be_nil
|
||||
cached_target["command"].should == Digest::MD5.hexdigest("the command".inspect)
|
||||
cached_target["checksum"].should == "the checksum"
|
||||
cached_target["deps"].should == [
|
||||
expect(cached_target["command"]).to eq Digest::MD5.hexdigest("the command".inspect)
|
||||
expect(cached_target["checksum"]).to eq "the checksum"
|
||||
expect(cached_target["deps"]).to eq [
|
||||
{"fname" => "dep 1", "checksum" => "dep 1 checksum"},
|
||||
{"fname" => "dep 2", "checksum" => "dep 2 checksum"},
|
||||
]
|
||||
cached_target["user_deps"].should == [
|
||||
expect(cached_target["user_deps"]).to eq [
|
||||
{"fname" => "user.dep", "checksum" => "user.dep checksum"},
|
||||
]
|
||||
end
|
||||
@@ -204,7 +204,7 @@ module Rscons
|
||||
describe "#targets" do
|
||||
it "returns a list of targets that are cached" do
|
||||
cache = {"targets" => {"t1" => {}, "t2" => {}, "t3" => {}}}
|
||||
build_from(cache).targets.should == ["t1", "t2", "t3"]
|
||||
expect(build_from(cache).targets).to eq ["t1", "t2", "t3"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -223,7 +223,7 @@ module Rscons
|
||||
FileUtils.should_receive(:mkdir).with("one/two/four")
|
||||
cache.mkdir_p("one/two/three")
|
||||
cache.mkdir_p("one\\two\\four")
|
||||
cache.directories.should == ["one/two", "one/two/three", "one/two/four"]
|
||||
expect(cache.directories).to eq ["one/two", "one/two/three", "one/two/four"]
|
||||
end
|
||||
|
||||
it "handles absolute paths" do
|
||||
@@ -233,14 +233,14 @@ module Rscons
|
||||
File.should_receive(:exists?).with("/one/two").and_return(false)
|
||||
FileUtils.should_receive(:mkdir).with("/one/two")
|
||||
cache.mkdir_p("/one/two")
|
||||
cache.directories.should == ["/one/two"]
|
||||
expect(cache.directories).to eq ["/one/two"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "#directories" do
|
||||
it "returns a list of directories that are cached" do
|
||||
_cache = {"directories" => {"dir1" => true, "dir2" => true}}
|
||||
build_from(_cache).directories.should == ["dir1", "dir2"]
|
||||
expect(build_from(_cache).directories).to eq ["dir1", "dir2"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -249,13 +249,13 @@ module Rscons
|
||||
cache = build_from({})
|
||||
cache.instance_variable_set(:@lookup_checksums, {"f1" => "f1.chk"})
|
||||
cache.should_not_receive(:calculate_checksum)
|
||||
cache.send(:lookup_checksum, "f1").should == "f1.chk"
|
||||
expect(cache.send(:lookup_checksum, "f1")).to eq "f1.chk"
|
||||
end
|
||||
|
||||
it "calls calculate_checksum when the checksum is not cached" do
|
||||
cache = build_from({})
|
||||
cache.should_receive(:calculate_checksum).with("f1").and_return("ck")
|
||||
cache.send(:lookup_checksum, "f1").should == "ck"
|
||||
expect(cache.send(:lookup_checksum, "f1")).to eq "ck"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -264,7 +264,7 @@ module Rscons
|
||||
contents = "contents"
|
||||
File.should_receive(:read).with("fname", mode: "rb").and_return(contents)
|
||||
Digest::MD5.should_receive(:hexdigest).with(contents).and_return("the_checksum")
|
||||
build_from({}).send(:calculate_checksum, "fname").should == "the_checksum"
|
||||
expect(build_from({}).send(:calculate_checksum, "fname")).to eq "the_checksum"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module Rscons
|
||||
it "adds the default builders when they are not excluded" do
|
||||
env = Environment.new
|
||||
env.builders.size.should be > 0
|
||||
env.builders.map {|name, builder| builder.is_a?(Builder)}.all?.should be_true
|
||||
expect(env.builders.map {|name, builder| builder.is_a?(Builder)}.all?).to be_true
|
||||
env.builders.find {|name, builder| name == "Object"}.should_not be_nil
|
||||
env.builders.find {|name, builder| name == "Program"}.should_not be_nil
|
||||
env.builders.find {|name, builder| name == "Library"}.should_not be_nil
|
||||
@@ -12,7 +12,7 @@ module Rscons
|
||||
|
||||
it "excludes the default builders with exclude_builders: :all" do
|
||||
env = Environment.new(exclude_builders: true)
|
||||
env.builders.size.should == 0
|
||||
expect(env.builders.size).to eq 0
|
||||
end
|
||||
|
||||
context "when a block is given" do
|
||||
@@ -30,8 +30,8 @@ module Rscons
|
||||
env["CPPPATH"] << "path1"
|
||||
env2 = env.clone
|
||||
env2["CPPPATH"] << "path2"
|
||||
env["CPPPATH"].should == ["path1"]
|
||||
env2["CPPPATH"].should == ["path1", "path2"]
|
||||
expect(env["CPPPATH"]).to eq ["path1"]
|
||||
expect(env2["CPPPATH"]).to eq ["path1", "path2"]
|
||||
end
|
||||
|
||||
it "supports nil, false, true, String, Symbol, Array, Hash, and Integer variables" do
|
||||
@@ -68,9 +68,9 @@ module Rscons
|
||||
describe "#add_builder" do
|
||||
it "adds the builder to the list of builders" do
|
||||
env = Environment.new(exclude_builders: true)
|
||||
env.builders.keys.should == []
|
||||
expect(env.builders.keys).to eq []
|
||||
env.add_builder(Rscons::Builders::Object.new)
|
||||
env.builders.keys.should == ["Object"]
|
||||
expect(env.builders.keys).to eq ["Object"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,20 +78,20 @@ module Rscons
|
||||
context "with no build directories" do
|
||||
it "returns the name of the source file with suffix changed" do
|
||||
env = Environment.new
|
||||
env.get_build_fname("src/dir/file.c", ".o").should == "src/dir/file.o"
|
||||
env.get_build_fname("src\\dir\\other.d", ".a").should == "src/dir/other.a"
|
||||
env.get_build_fname("source.cc", ".o").should == "source.o"
|
||||
expect(env.get_build_fname("src/dir/file.c", ".o")).to eq "src/dir/file.o"
|
||||
expect(env.get_build_fname("src\\dir\\other.d", ".a")).to eq "src/dir/other.a"
|
||||
expect(env.get_build_fname("source.cc", ".o")).to eq "source.o"
|
||||
end
|
||||
|
||||
context "with a build_root" do
|
||||
it "uses the build_root unless the path is absolute" do
|
||||
env = Environment.new
|
||||
env.build_root = "build/proj"
|
||||
env.get_build_fname("src/dir/file.c", ".o").should == "build/proj/src/dir/file.o"
|
||||
env.get_build_fname("/some/lib.c", ".a").should == "/some/lib.a"
|
||||
env.get_build_fname("C:\\abspath\\mod.cc", ".o").should == "C:/abspath/mod.o"
|
||||
env.get_build_fname("build\\proj\\generated.c", ".o").should == "build/proj/generated.o"
|
||||
env.get_build_fname("build/proj.XX", ".yy").should == "build/proj/build/proj.yy"
|
||||
expect(env.get_build_fname("src/dir/file.c", ".o")).to eq "build/proj/src/dir/file.o"
|
||||
expect(env.get_build_fname("/some/lib.c", ".a")).to eq "/some/lib.a"
|
||||
expect(env.get_build_fname("C:\\abspath\\mod.cc", ".o")).to eq "C:/abspath/mod.o"
|
||||
expect(env.get_build_fname("build\\proj\\generated.c", ".o")).to eq "build/proj/generated.o"
|
||||
expect(env.get_build_fname("build/proj.XX", ".yy")).to eq "build/proj/build/proj.yy"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -101,10 +101,10 @@ module Rscons
|
||||
env = Environment.new
|
||||
env.build_dir("src", "bld")
|
||||
env.build_dir(%r{^libs/([^/]+)}, 'build/libs/\1')
|
||||
env.get_build_fname("src/input.cc", ".o").should == "bld/input.o"
|
||||
env.get_build_fname("libs/lib1/some/file.c", ".o").should == "build/libs/lib1/some/file.o"
|
||||
env.get_build_fname("libs/otherlib/otherlib.cc", ".o").should == "build/libs/otherlib/otherlib.o"
|
||||
env.get_build_fname("other_directory/o.d", ".a").should == "other_directory/o.a"
|
||||
expect(env.get_build_fname("src/input.cc", ".o")).to eq "bld/input.o"
|
||||
expect(env.get_build_fname("libs/lib1/some/file.c", ".o")).to eq "build/libs/lib1/some/file.o"
|
||||
expect(env.get_build_fname("libs/otherlib/otherlib.cc", ".o")).to eq "build/libs/otherlib/otherlib.o"
|
||||
expect(env.get_build_fname("other_directory/o.d", ".a")).to eq "other_directory/o.a"
|
||||
end
|
||||
|
||||
context "with a build_root" do
|
||||
@@ -114,11 +114,11 @@ module Rscons
|
||||
env.build_dir(%r{^libs/([^/]+)}, 'build/libs/\1')
|
||||
env.build_root = "bldit"
|
||||
|
||||
env.get_build_fname("src/input.cc", ".o").should == "bld/input.o"
|
||||
env.get_build_fname("libs/lib1/some/file.c", ".o").should == "build/libs/lib1/some/file.o"
|
||||
env.get_build_fname("libs/otherlib/otherlib.cc", ".o").should == "build/libs/otherlib/otherlib.o"
|
||||
env.get_build_fname("other_directory/o.d", ".a").should == "bldit/other_directory/o.a"
|
||||
env.get_build_fname("bldit/some/mod.d", ".a").should == "bldit/some/mod.a"
|
||||
expect(env.get_build_fname("src/input.cc", ".o")).to eq "bld/input.o"
|
||||
expect(env.get_build_fname("libs/lib1/some/file.c", ".o")).to eq "build/libs/lib1/some/file.o"
|
||||
expect(env.get_build_fname("libs/otherlib/otherlib.cc", ".o")).to eq "build/libs/otherlib/otherlib.o"
|
||||
expect(env.get_build_fname("other_directory/o.d", ".a")).to eq "bldit/other_directory/o.a"
|
||||
expect(env.get_build_fname("bldit/some/mod.d", ".a")).to eq "bldit/some/mod.a"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -128,7 +128,7 @@ module Rscons
|
||||
it "allows reading construction variables" do
|
||||
env = Environment.new
|
||||
env["CFLAGS"] = ["-g", "-Wall"]
|
||||
env["CFLAGS"].should == ["-g", "-Wall"]
|
||||
expect(env["CFLAGS"]).to eq ["-g", "-Wall"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -138,9 +138,9 @@ module Rscons
|
||||
env["CFLAGS"] = ["-g", "-Wall"]
|
||||
env["CFLAGS"] -= ["-g"]
|
||||
env["CFLAGS"] += ["-O3"]
|
||||
env["CFLAGS"].should == ["-Wall", "-O3"]
|
||||
expect(env["CFLAGS"]).to eq ["-Wall", "-O3"]
|
||||
env["other_var"] = "val33"
|
||||
env["other_var"].should == "val33"
|
||||
expect(env["other_var"]).to eq "val33"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -150,8 +150,8 @@ module Rscons
|
||||
env["CFLAGS"] = ["-g"]
|
||||
env["CPPPATH"] = ["inc"]
|
||||
env.append("CFLAGS" => ["-Wall"], "CPPPATH" => ["include"])
|
||||
env["CFLAGS"].should == ["-Wall"]
|
||||
env["CPPPATH"].should == ["include"]
|
||||
expect(env["CFLAGS"]).to eq ["-Wall"]
|
||||
expect(env["CPPPATH"]).to eq ["include"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -234,7 +234,7 @@ module Rscons
|
||||
env["specialflag"] = "-z"
|
||||
template = ["cmd", "-I${path}", "${flags}", "${_source}", "${_dest}"]
|
||||
cmd = env.build_command(template, "_source" => "infile", "_dest" => "outfile")
|
||||
cmd.should == ["cmd", "-Idir1", "-Idir2", "-x", "-y", "-z", "infile", "outfile"]
|
||||
expect(cmd).to eq ["cmd", "-Idir1", "-Idir2", "-x", "-y", "-z", "infile", "outfile"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -245,11 +245,11 @@ module Rscons
|
||||
env["flags"] = ["-x", "-y", "${specialflag}"]
|
||||
env["specialflag"] = "-z"
|
||||
env["foo"] = {}
|
||||
env.expand_varref(["-p${path}", "${flags}"]).should == ["-pdir1", "-pdir2", "-x", "-y", "-z"]
|
||||
env.expand_varref("foo").should == "foo"
|
||||
expect(env.expand_varref(["-p${path}", "${flags}"])).to eq ["-pdir1", "-pdir2", "-x", "-y", "-z"]
|
||||
expect(env.expand_varref("foo")).to eq "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"]
|
||||
expect(env.expand_varref("${specialflag}")).to eq "-z"
|
||||
expect(env.expand_varref("${path}")).to eq ["dir1", "dir2"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -294,14 +294,14 @@ module Rscons
|
||||
|
||||
it "records the target when the target method is a known builder" do
|
||||
env = Environment.new
|
||||
env.instance_variable_get(:@targets).should == {}
|
||||
expect(env.instance_variable_get(:@targets)).to eq({})
|
||||
env.Object("target.o", ["src1.c", "src2.c"], var: "val")
|
||||
target = env.instance_variable_get(:@targets)["target.o"]
|
||||
target.should_not be_nil
|
||||
target[:builder].is_a?(Builder).should be_true
|
||||
target[:sources].should == ["src1.c", "src2.c"]
|
||||
target[:vars].should == {var: "val"}
|
||||
target[:args].should == []
|
||||
expect(target[:builder].is_a?(Builder)).to be_true
|
||||
expect(target[:sources]).to eq ["src1.c", "src2.c"]
|
||||
expect(target[:vars]).to eq({var: "val"})
|
||||
expect(target[:args]).to eq []
|
||||
end
|
||||
|
||||
it "raises an error when vars is not a Hash" do
|
||||
@@ -314,13 +314,13 @@ module Rscons
|
||||
it "records the given dependencies in @user_deps" do
|
||||
env = Environment.new
|
||||
env.depends("foo", "bar", "baz")
|
||||
env.instance_variable_get(:@user_deps).should == {"foo" => ["bar", "baz"]}
|
||||
expect(env.instance_variable_get(:@user_deps)).to eq({"foo" => ["bar", "baz"]})
|
||||
end
|
||||
it "records user dependencies only once" do
|
||||
env = Environment.new
|
||||
env.instance_variable_set(:@user_deps, {"foo" => ["bar"]})
|
||||
env.depends("foo", "bar", "baz")
|
||||
env.instance_variable_get(:@user_deps).should == {"foo" => ["bar", "baz"]}
|
||||
expect(env.instance_variable_get(:@user_deps)).to eq({"foo" => ["bar", "baz"]})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -337,7 +337,7 @@ module Rscons
|
||||
env.add_builder(ABuilder.new)
|
||||
env.builders["Object"].should_receive(:run).with("mod.o", ["mod.c"], cache, env, anything).and_return("mod.o")
|
||||
env.builders["ABuilder"].should_receive(:run).with("mod2.ab_out", ["mod2.ab_in"], cache, env, anything).and_return("mod2.ab_out")
|
||||
env.build_sources(["precompiled.o", "mod.c", "mod2.ab_in"], [".o", ".ab_out"], cache, {}).should == ["precompiled.o", "mod.o", "mod2.ab_out"]
|
||||
expect(env.build_sources(["precompiled.o", "mod.c", "mod2.ab_in"], [".o", ".ab_out"], cache, {})).to eq ["precompiled.o", "mod.o", "mod2.ab_out"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -350,11 +350,11 @@ module Rscons
|
||||
end
|
||||
end
|
||||
env.builders["Object"].stub(:run) do |target, sources, cache, env, vars|
|
||||
vars["CFLAGS"].should == []
|
||||
expect(vars["CFLAGS"]).to eq []
|
||||
end
|
||||
env.run_builder(env.builders["Object"], "build/normal/module.o", ["src/normal/module.c"], "cache", {})
|
||||
env.builders["Object"].stub(:run) do |target, sources, cache, env, vars|
|
||||
vars["CFLAGS"].should == ["-O3", "-DSPECIAL"]
|
||||
expect(vars["CFLAGS"]).to eq ["-O3", "-DSPECIAL"]
|
||||
end
|
||||
env.run_builder(env.builders["Object"], "build/special/module.o", ["src/special/module.c"], "cache", {})
|
||||
end
|
||||
@@ -438,7 +438,7 @@ module Rscons
|
||||
File.should_receive(:read).with('makefile').and_return(<<EOS)
|
||||
module.o: source.cc
|
||||
EOS
|
||||
Environment.parse_makefile_deps('makefile', 'module.o').should == ['source.cc']
|
||||
expect(Environment.parse_makefile_deps('makefile', 'module.o')).to eq ['source.cc']
|
||||
end
|
||||
|
||||
it 'handles dependencies split across many lines' do
|
||||
@@ -447,7 +447,7 @@ module.o: module.c \\
|
||||
module.h \\
|
||||
other.h
|
||||
EOS
|
||||
Environment.parse_makefile_deps('makefile', 'module.o').should == [
|
||||
expect(Environment.parse_makefile_deps('makefile', 'module.o')).to eq [
|
||||
'module.c', 'module.h', 'other.h']
|
||||
end
|
||||
end
|
||||
|
||||
+23
-23
@@ -3,20 +3,20 @@ module Rscons
|
||||
describe '#initialize' do
|
||||
it "initializes variables from a Hash" do
|
||||
v = VarSet.new({"one" => 1, "two" => :two})
|
||||
v["one"].should == 1
|
||||
v["two"].should == :two
|
||||
expect(v["one"]).to eq(1)
|
||||
expect(v["two"]).to eq(:two)
|
||||
end
|
||||
it "initializes variables from another VarSet" do
|
||||
v = VarSet.new({"one" => 1})
|
||||
v2 = VarSet.new(v)
|
||||
v2["one"].should == 1
|
||||
expect(v2["one"]).to eq 1
|
||||
end
|
||||
it "makes a deep copy of the given VarSet" do
|
||||
v = VarSet.new({"array" => [1, 2, 3]})
|
||||
v2 = VarSet.new(v)
|
||||
v["array"] << 4
|
||||
v["array"].should == [1, 2, 3, 4]
|
||||
v2["array"].should == [1, 2, 3]
|
||||
expect(v["array"]).to eq([1, 2, 3, 4])
|
||||
expect(v2["array"]).to eq([1, 2, 3])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,11 +24,11 @@ module Rscons
|
||||
it "allows accessing a variable with its verbatim value if type is not specified" do
|
||||
v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz,
|
||||
"qax" => [3, 6], "qux" => {a: :b}})
|
||||
v["fuz"].should == "a string"
|
||||
v["foo"].should == 42
|
||||
v["bar"].should == :baz
|
||||
v["qax"].should == [3, 6]
|
||||
v["qux"].should == {a: :b}
|
||||
expect(v["fuz"]).to eq("a string")
|
||||
expect(v["foo"]).to eq(42)
|
||||
expect(v["bar"]).to eq(:baz)
|
||||
expect(v["qax"]).to eq([3, 6])
|
||||
expect(v["qux"]).to eq({a: :b})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,8 +36,8 @@ module Rscons
|
||||
it "allows assigning to variables" do
|
||||
v = VarSet.new("CFLAGS" => ["-Wall", "-O3"])
|
||||
v["CPPPATH"] = ["one", "two"]
|
||||
v["CFLAGS"].should == ["-Wall", "-O3"]
|
||||
v["CPPPATH"].should == ["one", "two"]
|
||||
expect(v["CFLAGS"]).to eq(["-Wall", "-O3"])
|
||||
expect(v["CPPPATH"]).to eq(["one", "two"])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,29 +128,29 @@ module Rscons
|
||||
"cmd" => ["${CC}", "-c", "${CFLAGS}", "-I${CPPPATH}"],
|
||||
"hash" => {})
|
||||
it "expands to the string itself if the string is not a variable reference" do
|
||||
v.expand_varref("CC").should == "CC"
|
||||
v.expand_varref("CPPPATH").should == "CPPPATH"
|
||||
v.expand_varref("str").should == "str"
|
||||
expect(v.expand_varref("CC")).to eq("CC")
|
||||
expect(v.expand_varref("CPPPATH")).to eq("CPPPATH")
|
||||
expect(v.expand_varref("str")).to eq("str")
|
||||
end
|
||||
it "expands a single variable reference beginning with a '$'" do
|
||||
v.expand_varref("${CC}").should == "gcc"
|
||||
v.expand_varref("${CPPPATH}").should == ["dir1", "dir2"]
|
||||
expect(v.expand_varref("${CC}")).to eq("gcc")
|
||||
expect(v.expand_varref("${CPPPATH}")).to eq(["dir1", "dir2"])
|
||||
end
|
||||
it "expands a single variable reference in ${arr} notation" do
|
||||
v.expand_varref("prefix${CFLAGS}suffix").should == ["prefix-Wallsuffix", "prefix-O2suffix"]
|
||||
v.expand_varref(v["cmd"]).should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]
|
||||
expect(v.expand_varref("prefix${CFLAGS}suffix")).to eq(["prefix-Wallsuffix", "prefix-O2suffix"])
|
||||
expect(v.expand_varref(v["cmd"])).to eq(["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"])
|
||||
end
|
||||
it "expands a variable reference recursively" do
|
||||
v.expand_varref("${compiler}").should == "gcc"
|
||||
v.expand_varref("${cmd}").should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]
|
||||
expect(v.expand_varref("${compiler}")).to eq("gcc")
|
||||
expect(v.expand_varref("${cmd}")).to eq(["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"])
|
||||
end
|
||||
it "resolves multiple variable references in one element by enumerating all combinations" do
|
||||
v.expand_varref("cflag: ${CFLAGS}, cpppath: ${CPPPATH}, compiler: ${compiler}").should == [
|
||||
expect(v.expand_varref("cflag: ${CFLAGS}, cpppath: ${CPPPATH}, compiler: ${compiler}")).to eq([
|
||||
"cflag: -Wall, cpppath: dir1, compiler: gcc",
|
||||
"cflag: -O2, cpppath: dir1, compiler: gcc",
|
||||
"cflag: -Wall, cpppath: dir2, compiler: gcc",
|
||||
"cflag: -O2, cpppath: dir2, compiler: gcc",
|
||||
]
|
||||
])
|
||||
end
|
||||
it "returns an empty string when a variable reference refers to a non-existent variable" do
|
||||
expect(v.expand_varref("${not_here}")).to eq("")
|
||||
|
||||
Reference in new issue
Block a user