Write Cache to disk if an exception occurs while processing the Environment - fix #4
This commit is contained in:
parent
ea30b0b5ee
commit
ee5aca275d
@ -176,6 +176,7 @@ module Rscons
|
||||
cache.clear_checksum_cache!
|
||||
targets_processed = {}
|
||||
unless @targets.empty?
|
||||
begin
|
||||
process_target = proc do |target|
|
||||
targets_processed[target] ||= begin
|
||||
@targets[target][:sources].each do |src|
|
||||
@ -189,7 +190,6 @@ module Rscons
|
||||
cache,
|
||||
@targets[target][:vars] || {})
|
||||
unless result
|
||||
cache.write
|
||||
raise BuildError.new("Failed to build #{target}")
|
||||
end
|
||||
result
|
||||
@ -198,9 +198,11 @@ module Rscons
|
||||
@targets.each do |target, target_params|
|
||||
process_target.call(target)
|
||||
end
|
||||
ensure
|
||||
cache.write
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Clear all targets registered for the Environment.
|
||||
def clear_targets
|
||||
|
@ -176,6 +176,21 @@ module Rscons
|
||||
|
||||
expect { env.process }.to raise_error BuildError, /Failed.to.build.main.o/
|
||||
end
|
||||
|
||||
it "writes the cache when the Builder raises an exception" do
|
||||
env = Environment.new
|
||||
env.Object("module.o", "module.c")
|
||||
|
||||
cache = "cache"
|
||||
Cache.should_receive(:instance).and_return(cache)
|
||||
cache.should_receive(:clear_checksum_cache!)
|
||||
env.stub(:run_builder) do |builder, target, sources, cache, vars|
|
||||
raise "Ruby exception thrown by builder"
|
||||
end
|
||||
cache.should_receive(:write)
|
||||
|
||||
expect { env.process }.to raise_error RuntimeError, /Ruby exception thrown by builder/
|
||||
end
|
||||
end
|
||||
|
||||
describe "#clear_targets" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user