convert Object builder specs to integration tests

This commit is contained in:
josh committed 2017-05-22 16:38:57 -04:00
1 parent 2be738be4f
commit 7e707e7e3b
5 files changed
+39 -52

No files matched your search

+25
View File
@@ -935,4 +935,29 @@ EOF
end
end
context "Object builder" do
it "allows overriding CCCMD construction variable" do
test_dir("simple")
result = run_test(rsconsfile: "override_cccmd.rb")
expect(result.stderr).to eq ""
expect(lines(result.stdout)).to eq [
"gcc -c -o simple.o -Dfoobar simple.c",
]
end
it "allows overriding DEPFILESUFFIX construction variable" do
test_dir("simple")
result = run_test(rsconsfile: "override_depfilesuffix.rb")
expect(result.stderr).to eq ""
expect(lines(result.stdout)).to eq [
"gcc -c -o simple.o -MMD -MF simple.deppy simple.c",
]
end
it "raises an error when given a source file with an unknown suffix" do
test_dir("simple")
result = run_test(rsconsfile: "error_unknown_suffix.rb")
expect(result.stderr).to match /unknown input file type: "foo.xyz"/
end
end
end
-52
View File
@@ -1,52 +0,0 @@
module Rscons
module Builders
describe Object do
let(:env) {Environment.new}
let(:cache) {double(Cache)}
subject {Object.new}
it "supports overriding CCCMD construction variable" do
expect(cache).to receive(:up_to_date?).and_return(false)
expect(cache).to receive(:mkdir_p)
expect(FileUtils).to receive(:rm_f)
expect(env).to receive(:execute).with("CC mod.o", ["llc", "mod.c"]).and_return(true)
expect(File).to receive(:exists?).and_return(false)
expect(cache).to receive(:register_build)
subject.run(
target: "mod.o",
sources: ["mod.c"],
cache: cache,
env: env,
vars: {"CCCMD" => ["llc", "${_SOURCES}"]})
end
it "supports overriding DEPFILESUFFIX construction variable" do
expect(cache).to receive(:up_to_date?).and_return(false)
expect(cache).to receive(:mkdir_p)
expect(FileUtils).to receive(:rm_f)
expect(env).to receive(:execute).with(anything, %w[gcc -c -o f.o -MMD -MF f.d in.c]).and_return(true)
expect(File).to receive(:exists?).with("f.d").and_return(false)
expect(cache).to receive(:register_build)
subject.run(
target: "f.o",
sources: ["in.c"],
cache: cache,
env: env,
vars: {"DEPFILESUFFIX" => ".d"})
end
it "raises an error when given a source file with an unknown suffix" do
expect do
subject.run(
target: "mod.o",
sources: ["mod.xyz"],
cache: :cache,
env: env,
vars: {})
end.to raise_error /unknown input file type: "mod.xyz"/
end
end
end
end