Permalink
Browse files

ExtensionTask now generated clean and clobber tasks.

These new tasks remove temporary (build files) and binaries
already built.
  • Loading branch information...
1 parent 5e628e5 commit 187ebafae64873762548e65db57f99140b9224b2 @luislavena luislavena committed Nov 7, 2008
View
@@ -1,2 +1,3 @@
coverage
+doc/html
tmp
View
@@ -51,3 +51,21 @@ Feature: Compile C code into Ruby extensions.
And output of rake task 'compile:extension_one' do not contain /extension_two/
And binary extension 'extension_one' do exist in 'lib'
And binary extension 'extension_two' do not exist in 'lib'
+
+ Scenario: removing temporary files
+ Given a safe project directory
+ And scaffold code for extension 'extension_one'
+ And I've already successfully executed rake task 'compile'
+ When rake task 'clean' is invoked
+ Then rake task 'clean' succeeded
+ And binary extension 'extension_one' do exist in 'lib'
+ And 'tmp' folder do not exist
+
+ Scenario: clobbering binary and temporary files
+ Given a safe project directory
+ And scaffold code for extension 'extension_one'
+ And I've already successfully executed rake task 'compile'
+ When rake task 'clobber' is invoked
+ Then rake task 'clobber' succeeded
+ And binary extension 'extension_one' do not exist in 'lib'
+ And 'tmp' folder do not exist
@@ -18,5 +18,9 @@
end
Then /^'(.*)' folder is created$/ do |folder|
- File.exist?(folder).should be_true
+ File.directory?(folder).should be_true
+end
+
+Then /^'(.*)' folder do not exist$/ do |folder|
+ File.directory?(folder).should_not be_true
end
@@ -4,6 +4,7 @@
# gem developer/creators.
require 'rake'
+require 'rake/clean'
require 'rake/tasklib'
require 'rbconfig'
@@ -38,6 +39,9 @@ def define
directory "#{@tmp_dir}/#{@name}"
directory @lib_dir
+ # temporary dir should be on the cleaning
+ CLEAN.include(@tmp_dir)
+
# makefile depends of tmp_dir and config_script
# tmp/extension_name/Makefile
file makefile => [tmp_path, extconf] do
@@ -61,10 +65,13 @@ def define
cp tmp_binary, lib_binary
end
+ # clobbering should remove the binaries from lib_path
+ CLOBBER.include(lib_binary)
+
desc "Compile just the #{@name} extension"
task "compile:#{@name}" => [lib_binary]
- desc "Compile the extension(s)"
+ desc "Compile the extension(s)" unless Rake::Task.task_defined?('compile')
task "compile" => ["compile:#{@name}"]
end
@@ -137,6 +137,18 @@
Rake::Task["tmp/extension_one/Makefile"].prerequisites.should include("ext/extension_one/extconf.rb")
end
end
+
+ describe 'clean' do
+ it "should include 'tmp' in the pattern" do
+ CLEAN.should include('tmp')
+ end
+ end
+
+ describe 'clobber' do
+ it "should include 'lib/extension_one.{so,bundle}'" do
+ CLOBBER.should include("lib/#{ext_bin('extension_one')}")
+ end
+ end
end
end

0 comments on commit 187ebaf

Please sign in to comment.