update many specs to RSpec 3 format

This commit is contained in:
Josh Holtrop 2014-06-12 15:39:20 -04:00
parent 42597b2dac
commit 0778f043ee
10 changed files with 65 additions and 65 deletions

View File

@ -82,7 +82,7 @@ describe Rscons do
Rscons::Environment.new do |env|
env.Program('simple', Dir['*.c'])
end
expect(File.exists?('simple.o')).to be_true
expect(File.exists?('simple.o')).to be_truthy
expect(`./simple`).to eq "This is a simple C program\n"
end
@ -114,7 +114,7 @@ describe Rscons do
Rscons::Environment.new do |env|
env.Program('header', Dir['*.c'])
end
expect(File.exists?('header.o')).to be_true
expect(File.exists?('header.o')).to be_truthy
expect(`./header`).to eq "The value is 2\n"
end
@ -183,8 +183,8 @@ describe Rscons do
env.Program('build_dir', Dir['src/**/*.c'])
end
expect(`./build_dir`).to eq "Hello from two()\n"
expect(File.exists?('build_one/one.o')).to be_true
expect(File.exists?('build_two/two.o')).to be_true
expect(File.exists?('build_one/one.o')).to be_truthy
expect(File.exists?('build_two/two.o')).to be_truthy
end
it 'uses build directories before build root' do
@ -234,14 +234,14 @@ describe Rscons do
env.Program('build_dir', Dir['src/**/*.c'])
end
expect(`./build_dir`).to eq "Hello from two()\n"
expect(File.exists?('build_one/one.o')).to be_true
expect(File.exists?('build_two/two.o')).to be_true
expect(File.exists?('build_one/one.o')).to be_truthy
expect(File.exists?('build_two/two.o')).to be_truthy
Rscons.clean
expect(File.exists?('build_one/one.o')).to be_false
expect(File.exists?('build_two/two.o')).to be_false
expect(File.exists?('build_one')).to be_false
expect(File.exists?('build_two')).to be_false
expect(File.exists?('src/one/one.c')).to be_true
expect(File.exists?('build_one/one.o')).to be_falsey
expect(File.exists?('build_two/two.o')).to be_falsey
expect(File.exists?('build_one')).to be_falsey
expect(File.exists?('build_two')).to be_falsey
expect(File.exists?('src/one/one.c')).to be_truthy
end
it 'does not clean created directories if other non-rscons-generated files reside there' do
@ -252,15 +252,15 @@ describe Rscons do
env.Program('build_dir', Dir['src/**/*.c'])
end
expect(`./build_dir`).to eq "Hello from two()\n"
expect(File.exists?('build_one/one.o')).to be_true
expect(File.exists?('build_two/two.o')).to be_true
expect(File.exists?('build_one/one.o')).to be_truthy
expect(File.exists?('build_two/two.o')).to be_truthy
File.open('build_two/tmp', 'w') { |fh| fh.puts "dum" }
Rscons.clean
expect(File.exists?('build_one/one.o')).to be_false
expect(File.exists?('build_two/two.o')).to be_false
expect(File.exists?('build_one')).to be_false
expect(File.exists?('build_two')).to be_true
expect(File.exists?('src/one/one.c')).to be_true
expect(File.exists?('build_one/one.o')).to be_falsey
expect(File.exists?('build_two/two.o')).to be_falsey
expect(File.exists?('build_one')).to be_falsey
expect(File.exists?('build_two')).to be_truthy
expect(File.exists?('src/one/one.c')).to be_truthy
end
it 'allows Ruby classes as custom builders to be used to construct files' do
@ -283,7 +283,7 @@ EOF
end
expect(lines).to eq ["CC program.o", "LD program#{env["PROGSUFFIX"]}"]
expect(File.exists?('inc.h')).to be_true
expect(File.exists?('inc.h')).to be_truthy
expect(`./program`).to eq "The value is 5678\n"
end
@ -310,8 +310,8 @@ EOF
end
expect(lines).to eq ["CHGen inc.c", "CC program.o", "CC inc.o", "LD program#{env["PROGSUFFIX"]}"]
expect(File.exists?("inc.c")).to be_true
expect(File.exists?("inc.h")).to be_true
expect(File.exists?("inc.c")).to be_truthy
expect(File.exists?("inc.h")).to be_truthy
expect(`./program`).to eq "The value is 42\n"
File.open("inc.c", "w") {|fh| fh.puts "int THE_VALUE = 33;"}
@ -372,7 +372,7 @@ EOF
Rscons::Environment.new do |env|
env.Program('simple', Dir['*.cc'])
end
expect(File.exists?('simple.o')).to be_true
expect(File.exists?('simple.o')).to be_truthy
expect(`./simple`).to eq "This is a simple C++ program\n"
end
@ -387,7 +387,7 @@ EOF
'gcc -c -o two.o -MMD -MF two.mf two.c',
"gcc -o two_sources#{env["PROGSUFFIX"]} one.o two.o",
]
expect(File.exists?("two_sources#{env["PROGSUFFIX"]}")).to be_true
expect(File.exists?("two_sources#{env["PROGSUFFIX"]}")).to be_truthy
expect(`./two_sources`).to eq "This is a C program with two sources.\n"
end
@ -404,7 +404,7 @@ EOF
'gcc -c -o three.o -MMD -MF three.mf three.c',
"gcc -o library#{env["PROGSUFFIX"]} lib.a three.o",
]
expect(File.exists?("library#{env["PROGSUFFIX"]}")).to be_true
expect(File.exists?("library#{env["PROGSUFFIX"]}")).to be_truthy
expect(`ar t lib.a`).to eq "one.o\ntwo.o\n"
end
@ -423,7 +423,7 @@ EOF
env.Program('build_hook.exe', Dir['src/**/*.c'])
end
expect(`./build_hook`).to eq "Hello from two()\n"
lines.should =~ [
expect(lines).to match_array [
'gcc -c -o build_one/one.o -MMD -MF build_one/one.mf -Isrc/one/ -Isrc/two/ -O1 src/one/one.c',
'gcc -c -o build_two/two.o -MMD -MF build_two/two.mf -Isrc/one/ -Isrc/two/ -O2 src/two/two.c',
'gcc -o build_hook.exe build_one/one.o build_two/two.o',
@ -439,7 +439,7 @@ EOF
end
end
expect(lines).to eq ["CC simple.o", "LD simple.exe"]
expect(File.exists?('simple.o')).to be_true
expect(File.exists?('simple.o')).to be_truthy
expect(`./simple.exe`).to eq "This is a simple C program\n"
e2 = Rscons::Environment.new do |env|
program = env.Program('simple.exe', Dir['*.c'])
@ -480,8 +480,8 @@ EOF
env.Object("simple.o", "simple.c")
env.Disassemble("simple.txt", "simple.o")
end
expect(File.exists?("simple.txt")).to be_true
File.read("simple.txt").should =~ /Disassembly of section .text:/
expect(File.exists?("simple.txt")).to be_truthy
expect(File.read("simple.txt")).to match /Disassembly of section .text:/
end
it "supports preprocessing C sources" do
@ -490,7 +490,7 @@ EOF
env.Preprocess("simplepp.c", "simple.c")
env.Program("simple", "simplepp.c")
end
File.read("simplepp.c").should =~ /# \d+ "simple.c"/
expect(File.read("simplepp.c")).to match /# \d+ "simple.c"/
expect(`./simple`).to eq "This is a simple C program\n"
end
@ -500,7 +500,7 @@ EOF
env.Preprocess("simplepp.cc", "simple.cc")
env.Program("simple", "simplepp.cc")
end
File.read("simplepp.cc").should =~ /# \d+ "simple.cc"/
expect(File.read("simplepp.cc")).to match /# \d+ "simple.cc"/
expect(`./simple`).to eq "This is a simple C++ program\n"
end
@ -540,7 +540,7 @@ EOF
end
expect(lines).to eq ["CC program.o", "LD program#{env["PROGSUFFIX"]}"]
expect(File.exists?('inc.h')).to be_true
expect(File.exists?('inc.h')).to be_truthy
expect(`./program`).to eq "The value is 678\n"
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 []

View File

@ -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