update many specs to RSpec 3 format
This commit is contained in:
1 parent
42597b2dac
commit
0778f043ee
10 files changed
+65
-65
No files matched your search
@@ -5,18 +5,18 @@ module Rscons
|
||||
subject {CFile.new}
|
||||
|
||||
it "invokes bison to create a .c file from a .y file" do
|
||||
subject.should_receive(:standard_build).with("YACC parser.c", "parser.c", ["bison", "-d", "-o", "parser.c", "parser.y"], ["parser.y"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("YACC parser.c", "parser.c", ["bison", "-d", "-o", "parser.c", "parser.y"], ["parser.y"], env, :cache)
|
||||
subject.run("parser.c", ["parser.y"], :cache, env, {})
|
||||
end
|
||||
|
||||
it "invokes a custom lexer to create a .cc file from a .ll file" do
|
||||
env["LEX"] = "custom_lex"
|
||||
subject.should_receive(:standard_build).with("LEX lexer.cc", "lexer.cc", ["custom_lex", "-o", "lexer.cc", "parser.ll"], ["parser.ll"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("LEX lexer.cc", "lexer.cc", ["custom_lex", "-o", "lexer.cc", "parser.ll"], ["parser.ll"], env, :cache)
|
||||
subject.run("lexer.cc", ["parser.ll"], :cache, env, {})
|
||||
end
|
||||
|
||||
it "supports overriding construction variables" do
|
||||
subject.should_receive(:standard_build).with("LEX lexer.c", "lexer.c", ["hi", "parser.l"], ["parser.l"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("LEX lexer.c", "lexer.c", ["hi", "parser.l"], ["parser.l"], env, :cache)
|
||||
subject.run("lexer.c", ["parser.l"], :cache, env, "LEX_CMD" => ["hi", "${_SOURCES}"])
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ module Rscons
|
||||
cache.stub(:up_to_date?) { false }
|
||||
cache.stub(:mkdir_p) { }
|
||||
cache.stub(:register_build) { }
|
||||
env.should_receive(:execute).with("Disassemble a_file.txt", ["my_disasm", "a_file.exe"], anything).and_return(true)
|
||||
expect(env).to receive(:execute).with("Disassemble a_file.txt", ["my_disasm", "a_file.exe"], anything).and_return(true)
|
||||
subject.run("a_file.txt", ["a_file.exe"], cache, env, "DISASM_CMD" => ["my_disasm", "${_SOURCES}"])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,12 +5,12 @@ module Rscons
|
||||
subject {Library.new}
|
||||
|
||||
it "supports overriding AR construction variable" do
|
||||
subject.should_receive(:standard_build).with("AR prog.a", "prog.a", ["sp-ar", "rcs", "prog.a", "prog.o"], ["prog.o"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("AR prog.a", "prog.a", ["sp-ar", "rcs", "prog.a", "prog.o"], ["prog.o"], env, :cache)
|
||||
subject.run("prog.a", ["prog.o"], :cache, env, "AR" => "sp-ar")
|
||||
end
|
||||
|
||||
it "supports overriding ARCMD construction variable" do
|
||||
subject.should_receive(:standard_build).with("AR prog.a", "prog.a", ["special", "AR!", "prog.o"], ["prog.o"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("AR prog.a", "prog.a", ["special", "AR!", "prog.o"], ["prog.o"], env, :cache)
|
||||
subject.run("prog.a", ["prog.o"], :cache, env, "ARCMD" => ["special", "AR!", "${_SOURCES}"])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module Rscons
|
||||
cache.stub(:register_build) { }
|
||||
FileUtils.stub(:rm_f) { }
|
||||
File.stub(:exists?) { false }
|
||||
env.should_receive(:execute).with("CC mod.o", ["llc", "mod.c"]).and_return(true)
|
||||
expect(env).to receive(:execute).with("CC mod.o", ["llc", "mod.c"]).and_return(true)
|
||||
subject.run("mod.o", ["mod.c"], cache, env, "CCCMD" => ["llc", "${_SOURCES}"])
|
||||
end
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ module Rscons
|
||||
subject {Preprocess.new}
|
||||
|
||||
it "supports overriding CC construction variable" do
|
||||
subject.should_receive(:standard_build).with("Preprocess module.pp", "module.pp", ["my_cpp", "-E", "-o", "module.pp", "module.c"], ["module.c"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("Preprocess module.pp", "module.pp", ["my_cpp", "-E", "-o", "module.pp", "module.c"], ["module.c"], env, :cache)
|
||||
subject.run("module.pp", ["module.c"], :cache, env, "CC" => "my_cpp")
|
||||
end
|
||||
|
||||
it "supports overriding CPP_CMD construction variable" do
|
||||
subject.should_receive(:standard_build).with("Preprocess module.pp", "module.pp", ["my_cpp", "module.c"], ["module.c"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("Preprocess module.pp", "module.pp", ["my_cpp", "module.c"], ["module.c"], env, :cache)
|
||||
subject.run("module.pp", ["module.c"], :cache, env, "CPP_CMD" => ["my_cpp", "${_SOURCES}"])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,12 +5,12 @@ module Rscons
|
||||
subject {Program.new}
|
||||
|
||||
it "supports overriding CC construction variable" do
|
||||
subject.should_receive(:standard_build).with("LD prog", "prog", ["sp-c++", "-o", "prog", "prog.o"], ["prog.o"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("LD prog", "prog", ["sp-c++", "-o", "prog", "prog.o"], ["prog.o"], env, :cache)
|
||||
subject.run("prog", ["prog.o"], :cache, env, "CC" => "sp-c++")
|
||||
end
|
||||
|
||||
it "supports overriding LDCMD construction variable" do
|
||||
subject.should_receive(:standard_build).with("LD prog.exe", "prog.exe", ["special", "LD!", "prog.o"], ["prog.o"], env, :cache)
|
||||
expect(subject).to receive(:standard_build).with("LD prog.exe", "prog.exe", ["special", "LD!", "prog.o"], ["prog.o"], env, :cache)
|
||||
subject.run("prog.exe", ["prog.o"], :cache, env, "LDCMD" => ["special", "LD!", "${_SOURCES}"])
|
||||
end
|
||||
end
|
||||
|
||||
+11
-11
@@ -20,7 +20,7 @@ module Rscons
|
||||
$stderr.should_receive(:puts).with(/Warning:.*was.corrupt/)
|
||||
c = Cache.instance
|
||||
c.send(:initialize!)
|
||||
expect(c.instance_variable_get(:@cache).is_a?(Hash)).to be_true
|
||||
expect(c.instance_variable_get(:@cache).is_a?(Hash)).to be_truthy
|
||||
end
|
||||
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)
|
||||
expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_falsey
|
||||
end
|
||||
|
||||
it "returns false when target is not registered in the cache" do
|
||||
File.should_receive(:exists?).with("target").and_return(true)
|
||||
expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", [], empty_env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", [], empty_env)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", [], empty_env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env, strict_deps: true)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env, strict_deps: true)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1"], env)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1"], env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], env)).to be_false
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], env)).to be_falsey
|
||||
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")
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_true
|
||||
expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_truthy
|
||||
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
|
||||
expect(env.builders.map {|name, builder| builder.is_a?(Builder)}.all?).to be_true
|
||||
expect(env.builders.map {|name, builder| builder.is_a?(Builder)}.all?).to be_truthy
|
||||
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
|
||||
@@ -298,7 +298,7 @@ module Rscons
|
||||
env.Object("target.o", ["src1.c", "src2.c"], var: "val")
|
||||
target = env.instance_variable_get(:@targets)["target.o"]
|
||||
target.should_not be_nil
|
||||
expect(target[:builder].is_a?(Builder)).to be_true
|
||||
expect(target[:builder].is_a?(Builder)).to be_truthy
|
||||
expect(target[:sources]).to eq ["src1.c", "src2.c"]
|
||||
expect(target[:vars]).to eq({var: "val"})
|
||||
expect(target[:args]).to eq []
|
||||
|
||||
+10
-10
@@ -45,20 +45,20 @@ module Rscons
|
||||
it "returns whether the variable is in the VarSet" do
|
||||
v = VarSet.new("CFLAGS" => [], :foo => :bar)
|
||||
|
||||
expect(v.include?("CFLAGS")).to be_true
|
||||
expect(v.include?(:CFLAGS)).to be_false
|
||||
expect(v.include?(:foo)).to be_true
|
||||
expect(v.include?("foo")).to be_false
|
||||
expect(v.include?("bar")).to be_false
|
||||
expect(v.include?("CFLAGS")).to be_truthy
|
||||
expect(v.include?(:CFLAGS)).to be_falsey
|
||||
expect(v.include?(:foo)).to be_truthy
|
||||
expect(v.include?("foo")).to be_falsey
|
||||
expect(v.include?("bar")).to be_falsey
|
||||
|
||||
v2 = v.clone
|
||||
v2.append("bar" => [])
|
||||
|
||||
expect(v2.include?("CFLAGS")).to be_true
|
||||
expect(v2.include?(:CFLAGS)).to be_false
|
||||
expect(v2.include?(:foo)).to be_true
|
||||
expect(v2.include?("foo")).to be_false
|
||||
expect(v2.include?("bar")).to be_true
|
||||
expect(v2.include?("CFLAGS")).to be_truthy
|
||||
expect(v2.include?(:CFLAGS)).to be_falsey
|
||||
expect(v2.include?(:foo)).to be_truthy
|
||||
expect(v2.include?("foo")).to be_falsey
|
||||
expect(v2.include?("bar")).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user