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!
|
cache.clear_checksum_cache!
|
||||||
targets_processed = {}
|
targets_processed = {}
|
||||||
unless @targets.empty?
|
unless @targets.empty?
|
||||||
|
begin
|
||||||
process_target = proc do |target|
|
process_target = proc do |target|
|
||||||
targets_processed[target] ||= begin
|
targets_processed[target] ||= begin
|
||||||
@targets[target][:sources].each do |src|
|
@targets[target][:sources].each do |src|
|
||||||
@ -189,7 +190,6 @@ module Rscons
|
|||||||
cache,
|
cache,
|
||||||
@targets[target][:vars] || {})
|
@targets[target][:vars] || {})
|
||||||
unless result
|
unless result
|
||||||
cache.write
|
|
||||||
raise BuildError.new("Failed to build #{target}")
|
raise BuildError.new("Failed to build #{target}")
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
@ -198,9 +198,11 @@ module Rscons
|
|||||||
@targets.each do |target, target_params|
|
@targets.each do |target, target_params|
|
||||||
process_target.call(target)
|
process_target.call(target)
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
cache.write
|
cache.write
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Clear all targets registered for the Environment.
|
# Clear all targets registered for the Environment.
|
||||||
def clear_targets
|
def clear_targets
|
||||||
|
@ -176,6 +176,21 @@ module Rscons
|
|||||||
|
|
||||||
expect { env.process }.to raise_error BuildError, /Failed.to.build.main.o/
|
expect { env.process }.to raise_error BuildError, /Failed.to.build.main.o/
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "#clear_targets" do
|
describe "#clear_targets" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user