add integration test to verify cache is written if a builder fails
This commit is contained in:
parent
3601359c08
commit
551b8fa365
@ -2,7 +2,6 @@ require "digest/md5"
|
||||
require "fileutils"
|
||||
require "json"
|
||||
require "set"
|
||||
require "singleton"
|
||||
require "rscons/version"
|
||||
|
||||
module Rscons
|
||||
@ -51,7 +50,6 @@ module Rscons
|
||||
# },
|
||||
# }
|
||||
class Cache
|
||||
include Singleton
|
||||
|
||||
# Name of the file to store cache information in
|
||||
CACHE_FILE = ".rsconscache"
|
||||
@ -59,6 +57,18 @@ module Rscons
|
||||
# Prefix for phony cache entries.
|
||||
PHONY_PREFIX = ":PHONY:"
|
||||
|
||||
class << self
|
||||
# Access the singleton instance.
|
||||
def instance
|
||||
@instance ||= Cache.new
|
||||
end
|
||||
|
||||
# Reset the cache (for unit/integration test purposes)
|
||||
def reset!
|
||||
@instance = nil
|
||||
end
|
||||
end
|
||||
|
||||
# Create a Cache object and load in the previous contents from the cache
|
||||
# file.
|
||||
def initialize
|
||||
|
@ -54,6 +54,7 @@ describe Rscons do
|
||||
def test_dir(build_test_directory)
|
||||
FileUtils.cp_r("build_tests/#{build_test_directory}", BUILD_TEST_RUN_DIR)
|
||||
Dir.chdir(BUILD_TEST_RUN_DIR)
|
||||
@saved_stderr.reopen(".stderr")
|
||||
end
|
||||
|
||||
def file_sub(fname)
|
||||
@ -798,6 +799,38 @@ EOF
|
||||
])
|
||||
end
|
||||
|
||||
it "does not re-run previously successful builders if one fails" do
|
||||
test_dir('simple')
|
||||
File.open("two.c", "w") do |fh|
|
||||
fh.puts("FOO")
|
||||
end
|
||||
expect do
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple", %w[simple.c two.c])
|
||||
end
|
||||
end.to raise_error /Failed to build simple/
|
||||
result = lines
|
||||
expect(result.size).to be > 2
|
||||
expect(result[0, 2]).to eq [
|
||||
"CC simple.o",
|
||||
"CC two.o",
|
||||
]
|
||||
expect(File.exists?("simple.o")).to be_truthy
|
||||
expect(File.exists?("two.o")).to be_falsey
|
||||
expect(File.exists?("two_sources#{Rscons::Environment.new["PROGSUFFIX"]}")).to be_falsey
|
||||
|
||||
Rscons::Cache.reset!
|
||||
|
||||
File.open("two.c", "w") {|fh|}
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple", %w[simple.c two.c])
|
||||
end
|
||||
expect(lines).to eq [
|
||||
"CC two.o",
|
||||
"LD simple",
|
||||
]
|
||||
end
|
||||
|
||||
context "Directory builder" do
|
||||
it "creates the requested directory" do
|
||||
test_dir("simple")
|
||||
|
Loading…
x
Reference in New Issue
Block a user