implement distclean operation - close #81
This commit is contained in:
parent
93ffed2eb2
commit
a98c111cd2
5
build_tests/simple/distclean.rb
Normal file
5
build_tests/simple/distclean.rb
Normal file
@ -0,0 +1,5 @@
|
||||
build do
|
||||
Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
end
|
||||
end
|
@ -51,6 +51,8 @@ module Rscons
|
||||
clean
|
||||
when "configure"
|
||||
configure(operation_options)
|
||||
when "distclean"
|
||||
distclean
|
||||
else
|
||||
$stderr.puts "Unknown operation: #{operation}"
|
||||
1
|
||||
@ -100,6 +102,19 @@ module Rscons
|
||||
0
|
||||
end
|
||||
|
||||
# Remove the build directory and clear the cache.
|
||||
#
|
||||
# @return [Integer]
|
||||
# Exit code.
|
||||
def distclean
|
||||
cache = Cache.instance
|
||||
build_dir = cache.configuration_data["build_dir"]
|
||||
clean
|
||||
FileUtils.rm_rf(build_dir)
|
||||
cache.clear
|
||||
0
|
||||
end
|
||||
|
||||
# Configure the project.
|
||||
#
|
||||
# @param options [Hash]
|
||||
|
@ -1895,4 +1895,21 @@ EOF
|
||||
end
|
||||
end
|
||||
|
||||
context "distclean" do
|
||||
it "removes built files and the build directory" do
|
||||
test_dir "simple"
|
||||
result = run_rscons(rsconscript: "distclean.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
expect(File.exists?("simple.o")).to be_truthy
|
||||
expect(File.exists?("build")).to be_truthy
|
||||
result = run_rscons(rsconscript: "distclean.rb", op: "distclean")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
expect(File.exists?("simple.o")).to be_falsey
|
||||
expect(File.exists?("build")).to be_falsey
|
||||
expect(File.exists?(Rscons::Cache::CACHE_FILE)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user