a clean operation should preserve install target cache info - close #101
This commit is contained in:
parent
49e1bca1f7
commit
785e8e18fd
@ -114,16 +114,18 @@ module Rscons
|
|||||||
cache = Cache.instance
|
cache = Cache.instance
|
||||||
# remove all built files
|
# remove all built files
|
||||||
cache.targets(false).each do |target|
|
cache.targets(false).each do |target|
|
||||||
|
cache.remove_target(target)
|
||||||
FileUtils.rm_f(target)
|
FileUtils.rm_f(target)
|
||||||
end
|
end
|
||||||
# remove all created directories if they are empty
|
# remove all created directories if they are empty
|
||||||
cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|
|
cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|
|
||||||
|
cache.remove_directory(directory)
|
||||||
next unless File.directory?(directory)
|
next unless File.directory?(directory)
|
||||||
if (Dir.entries(directory) - ['.', '..']).empty?
|
if (Dir.entries(directory) - ['.', '..']).empty?
|
||||||
Dir.rmdir(directory) rescue nil
|
Dir.rmdir(directory) rescue nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cache.clear
|
cache.write
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -350,6 +350,28 @@ EOF
|
|||||||
expect(File.exists?("build/e.1/src/one/one.o")).to be_falsey
|
expect(File.exists?("build/e.1/src/one/one.o")).to be_falsey
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not remove install cache entries" do
|
||||||
|
test_dir "typical"
|
||||||
|
|
||||||
|
Dir.mktmpdir do |prefix|
|
||||||
|
result = run_rscons(rsconscript: "install.rb", op: %W[configure --prefix=#{prefix}])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
|
||||||
|
result = run_rscons(rsconscript: "install.rb", op: %W[install])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
|
||||||
|
result = run_rscons(rsconscript: "install.rb", op: %W[clean])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(File.exists?("#{prefix}/bin/program.exe")).to be_truthy
|
||||||
|
expect(File.exists?("build/e.1/src/one/one.o")).to be_falsey
|
||||||
|
|
||||||
|
result = run_rscons(rsconscript: "install.rb", op: %W[uninstall -v])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.stdout).to match %r{Removing #{prefix}/bin/program.exe}
|
||||||
|
expect(Dir.entries(prefix)).to match_array %w[. ..]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows Ruby classes as custom builders to be used to construct files' do
|
it 'allows Ruby classes as custom builders to be used to construct files' do
|
||||||
@ -1175,16 +1197,6 @@ EOF
|
|||||||
expect(result.stderr).to match /Warning.*was corrupt. Contents:/
|
expect(result.stderr).to match /Warning.*was corrupt. Contents:/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "removes the cache file on a clean operation" do
|
|
||||||
test_dir("simple")
|
|
||||||
result = run_rscons
|
|
||||||
expect(result.stderr).to eq ""
|
|
||||||
expect(File.exists?(Rscons::Cache::CACHE_FILE)).to be_truthy
|
|
||||||
result = run_rscons(op: %w[clean])
|
|
||||||
expect(result.stderr).to eq ""
|
|
||||||
expect(File.exists?(Rscons::Cache::CACHE_FILE)).to be_falsey
|
|
||||||
end
|
|
||||||
|
|
||||||
it "forces a build when the target file does not exist and is not in the cache" do
|
it "forces a build when the target file does not exist and is not in the cache" do
|
||||||
test_dir("simple")
|
test_dir("simple")
|
||||||
expect(File.exists?("simple.exe")).to be_falsey
|
expect(File.exists?("simple.exe")).to be_falsey
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
module Rscons
|
|
||||||
describe Application do
|
|
||||||
|
|
||||||
describe ".clean" do
|
|
||||||
it "removes all build targets and created directories" do
|
|
||||||
cache = "cache"
|
|
||||||
expect(Rscons::Cache).to receive(:instance).and_return(cache)
|
|
||||||
expect(cache).to receive(:targets).and_return(["build/a.out", "build/main.o"])
|
|
||||||
expect(FileUtils).to receive(:rm_f).with("build/a.out")
|
|
||||||
expect(FileUtils).to receive(:rm_f).with("build/main.o")
|
|
||||||
expect(cache).to receive(:directories).and_return(["build/one", "build/one/two", "build", "other"])
|
|
||||||
expect(File).to receive(:directory?).with("build/one/two").and_return(true)
|
|
||||||
expect(Dir).to receive(:entries).with("build/one/two").and_return([".", ".."])
|
|
||||||
expect(Dir).to receive(:rmdir).with("build/one/two")
|
|
||||||
expect(File).to receive(:directory?).with("build/one").and_return(true)
|
|
||||||
expect(Dir).to receive(:entries).with("build/one").and_return([".", ".."])
|
|
||||||
expect(Dir).to receive(:rmdir).with("build/one")
|
|
||||||
expect(File).to receive(:directory?).with("build").and_return(true)
|
|
||||||
expect(Dir).to receive(:entries).with("build").and_return([".", ".."])
|
|
||||||
expect(Dir).to receive(:rmdir).with("build")
|
|
||||||
expect(File).to receive(:directory?).with("other").and_return(true)
|
|
||||||
expect(Dir).to receive(:entries).with("other").and_return([".", "..", "other.file"])
|
|
||||||
expect(cache).to receive(:clear)
|
|
||||||
|
|
||||||
Rscons.application.__send__(:clean)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user