convert Object builder specs to integration tests
This commit is contained in:
parent
2be738be4f
commit
7e707e7e3b
6
build_tests/simple/error_unknown_suffix.rb
Normal file
6
build_tests/simple/error_unknown_suffix.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
File.open("foo.xyz", "wb") do |fh|
|
||||
fh.puts("hi")
|
||||
end
|
||||
env.Object("foo.o", "foo.xyz")
|
||||
end
|
4
build_tests/simple/override_cccmd.rb
Normal file
4
build_tests/simple/override_cccmd.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Object("simple.o", "simple.c",
|
||||
"CCCMD" => %w[${CC} -c -o ${_TARGET} -Dfoobar ${_SOURCES}])
|
||||
end
|
4
build_tests/simple/override_depfilesuffix.rb
Normal file
4
build_tests/simple/override_depfilesuffix.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["DEPFILESUFFIX"] = ".deppy"
|
||||
env.Object("simple.o", "simple.c")
|
||||
end
|
@ -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
|
||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user