uninstall operation should list removed entities in verbose mode - close #102
This commit is contained in:
parent
fd054a07c4
commit
49e1bca1f7
@ -167,15 +167,21 @@ module Rscons
|
||||
def uninstall
|
||||
cache = Cache.instance
|
||||
cache.targets(true).each do |target|
|
||||
cache.remove_target(target)
|
||||
next unless File.exists?(target)
|
||||
puts "Removing #{target}" if verbose
|
||||
FileUtils.rm_f(target)
|
||||
end
|
||||
# remove all created directories if they are empty
|
||||
cache.directories(true).sort {|a, b| b.size <=> a.size}.each do |directory|
|
||||
cache.remove_directory(directory)
|
||||
next unless File.directory?(directory)
|
||||
if (Dir.entries(directory) - ['.', '..']).empty?
|
||||
puts "Removing #{directory}" if verbose
|
||||
Dir.rmdir(directory) rescue nil
|
||||
end
|
||||
end
|
||||
cache.write
|
||||
0
|
||||
end
|
||||
|
||||
|
@ -320,6 +320,20 @@ module Rscons
|
||||
end.map(&:first)
|
||||
end
|
||||
|
||||
# Remove a target from the cache.
|
||||
#
|
||||
# @return [void]
|
||||
def remove_target(target)
|
||||
@cache["targets"].delete(target)
|
||||
end
|
||||
|
||||
# Remove a directory from the cache.
|
||||
#
|
||||
# @return [void]
|
||||
def remove_directory(directory)
|
||||
@cache["directories"].delete(directory)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Return a String key based on the target name to use in the on-disk cache.
|
||||
|
@ -2207,11 +2207,54 @@ EOF
|
||||
|
||||
result = run_rscons(rsconscript: "install.rb", op: %W[uninstall])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to_not match /Removing/
|
||||
expect(File.exists?("#{prefix}/bin/program.exe")).to be_falsey
|
||||
expect(File.exists?("build/e.1/src/one/one.o")).to be_truthy
|
||||
expect(Dir.entries(prefix)).to match_array %w[. ..]
|
||||
end
|
||||
end
|
||||
|
||||
it "prints removed files and directories when running verbosely" 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[uninstall -v])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match %r{Removing #{prefix}/bin/program.exe}
|
||||
expect(File.exists?("#{prefix}/bin/program.exe")).to be_falsey
|
||||
expect(Dir.entries(prefix)).to match_array %w[. ..]
|
||||
end
|
||||
end
|
||||
|
||||
it "removes cache entries when uninstalling" 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[uninstall -v])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match %r{Removing #{prefix}/bin/program.exe}
|
||||
expect(File.exists?("#{prefix}/bin/program.exe")).to be_falsey
|
||||
expect(Dir.entries(prefix)).to match_array %w[. ..]
|
||||
|
||||
FileUtils.mkdir_p("#{prefix}/bin")
|
||||
File.open("#{prefix}/bin/program.exe", "w") {|fh| fh.write("hi")}
|
||||
result = run_rscons(rsconscript: "install.rb", op: %W[uninstall -v])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to_not match /Removing/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user