Rework builder interface to only use #run method - close #91
The builder's #run method will be called repeatedly until it returns true or false. The Builder#wait_for method can be used to cause a builder to wait for a Thread, Command, or another Builder.
This commit is contained in:
1 parent
8426a54a57
commit
b882f8de99
38 files changed
+580
-665
No files matched your search
@@ -327,6 +327,29 @@ EOF
|
||||
expect(`./program.exe`).to eq "The value is 42\n"
|
||||
end
|
||||
|
||||
it 'raises an error when a custom builder returns an invalid value from #run' do
|
||||
test_dir("custom_builder")
|
||||
result = run_rscons(rsconscript: "error_run_return_value.rb")
|
||||
expect(result.stderr).to match /Unrecognized MyBuilder builder return value: "hi"/
|
||||
expect(result.status).to_not eq 0
|
||||
end
|
||||
|
||||
it 'raises an error when a custom builder returns an invalid value using Builder#wait_for' do
|
||||
test_dir("custom_builder")
|
||||
result = run_rscons(rsconscript: "error_wait_for.rb")
|
||||
expect(result.stderr).to match /Unrecognized MyBuilder builder return item: 1/
|
||||
expect(result.status).to_not eq 0
|
||||
end
|
||||
|
||||
it 'supports a Builder waiting for a custom Thread object' do
|
||||
test_dir "custom_builder"
|
||||
result = run_rscons(rsconscript: "wait_for_thread.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
expect(lines(result.stdout)).to include "MyBuilder foo"
|
||||
expect(File.exists?("foo")).to be_truthy
|
||||
end
|
||||
|
||||
it 'allows cloning Environment objects' do
|
||||
test_dir('clone_env')
|
||||
result = run_rscons
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
describe SimpleBuilder do
|
||||
let(:env) {Environment.new}
|
||||
|
||||
it "should create a new builder with the given action" do
|
||||
builder = Rscons::Builders::SimpleBuilder.new({}) { 0x1234 }
|
||||
expect(builder.run(1,2,3,4,5)).to eq(0x1234)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -230,7 +230,7 @@ module Rscons
|
||||
describe "#find_finished_thread" do
|
||||
it "raises an error if called with nonblock=false and no threads to wait for" do
|
||||
env = Environment.new
|
||||
expect {env.__send__(:find_finished_thread, [], false)}.to raise_error /No threads to wait for/
|
||||
expect {env.__send__(:find_finished_thread, false)}.to raise_error /No threads to wait for/
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user