add backwards-compatibility test for Builder#standard_build
This commit is contained in:
parent
b454208117
commit
83226e894d
17
build_tests/simple/standard_build.rb
Normal file
17
build_tests/simple/standard_build.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class MyCommand < Rscons::Builder
|
||||||
|
def run(target, sources, cache, env, vars)
|
||||||
|
vars = vars.merge({
|
||||||
|
"_TARGET" => target,
|
||||||
|
"_SOURCES" => sources,
|
||||||
|
})
|
||||||
|
command = env.build_command("${CMD}", vars)
|
||||||
|
cmd_desc = vars["CMD_DESC"] || "MyCommand"
|
||||||
|
standard_build("#{cmd_desc} #{target}", target, command, sources, env, cache)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.add_builder(MyCommand.new)
|
||||||
|
command = %w[gcc -c -o ${_TARGET} ${_SOURCES}]
|
||||||
|
env.MyCommand("simple.o", "simple.c", "CMD" => command)
|
||||||
|
end
|
@ -631,35 +631,44 @@ EOF
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows a builder to call Environment#run_builder in a non-threaded manner" do
|
context "backward compatibility" do
|
||||||
test_dir("simple")
|
it "allows a builder to call Environment#run_builder in a non-threaded manner" do
|
||||||
result = run_test(rsconsfile: "run_builder.rb")
|
test_dir("simple")
|
||||||
expect(result.stderr).to eq ""
|
result = run_test(rsconsfile: "run_builder.rb")
|
||||||
expect(lines(result.stdout)).to eq [
|
expect(result.stderr).to eq ""
|
||||||
"CC simple.o",
|
expect(lines(result.stdout)).to eq [
|
||||||
"LD simple.exe",
|
"CC simple.o",
|
||||||
]
|
"LD simple.exe",
|
||||||
end
|
]
|
||||||
|
end
|
||||||
it "allows a builder to call Environment#build_sources in a non-threaded manner" do
|
|
||||||
test_dir("simple")
|
it "allows a builder to call Environment#build_sources in a non-threaded manner" do
|
||||||
result = run_test(rsconsfile: "build_sources.rb")
|
test_dir("simple")
|
||||||
expect(result.stderr).to eq ""
|
result = run_test(rsconsfile: "build_sources.rb")
|
||||||
expect(lines(result.stdout)).to eq [
|
expect(result.stderr).to eq ""
|
||||||
"CC simple.o",
|
expect(lines(result.stdout)).to eq [
|
||||||
"CC two.o",
|
"CC simple.o",
|
||||||
"MyProgram simple.exe",
|
"CC two.o",
|
||||||
]
|
"MyProgram simple.exe",
|
||||||
end
|
]
|
||||||
|
end
|
||||||
it "prints the failed build command for a threaded builder when called via Environment#run_builder without delayed execution" do
|
|
||||||
test_dir("simple")
|
it "prints the failed build command for a threaded builder when called via Environment#run_builder without delayed execution" do
|
||||||
File.open("simple.c", "wb") do |fh|
|
test_dir("simple")
|
||||||
fh.write("FOOBAR")
|
File.open("simple.c", "wb") do |fh|
|
||||||
|
fh.write("FOOBAR")
|
||||||
|
end
|
||||||
|
result = run_test(rsconsfile: "run_builder.rb")
|
||||||
|
expect(result.stderr).to match /Failed to build/
|
||||||
|
expect(result.stdout).to match /Failed command was: gcc/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "supports builders that call Builder#standard_build" do
|
||||||
|
test_dir("simple")
|
||||||
|
result = run_test(rsconsfile: "standard_build.rb")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(lines(result.stdout)).to eq ["MyCommand simple.o"]
|
||||||
end
|
end
|
||||||
result = run_test(rsconsfile: "run_builder.rb")
|
|
||||||
expect(result.stderr).to match /Failed to build/
|
|
||||||
expect(result.stdout).to match /Failed command was: gcc/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Directory builder" do
|
context "Directory builder" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user