aboutsummaryrefslogtreecommitdiffstats
path: root/test/rake/test_rake_file_creation_task.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-23 22:11:55 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-23 22:11:55 +0000
commitd001539a0538cba0e48be2ebdafe29e67b006a4e (patch)
treeabf1591ca3b56f04f46cc2cce9918700620a3ab1 /test/rake/test_rake_file_creation_task.rb
parent3fbc9440feb66cf762834b6d66e6f3a893bab5b7 (diff)
downloadruby-d001539a0538cba0e48be2ebdafe29e67b006a4e.tar.gz
* lib/rake: Import Rake 0.9.2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/test_rake_file_creation_task.rb')
-rw-r--r--test/rake/test_rake_file_creation_task.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/rake/test_rake_file_creation_task.rb b/test/rake/test_rake_file_creation_task.rb
new file mode 100644
index 0000000000..d486d2f0d4
--- /dev/null
+++ b/test/rake/test_rake_file_creation_task.rb
@@ -0,0 +1,56 @@
+require File.expand_path('../helper', __FILE__)
+require 'fileutils'
+
+######################################################################
+class TestRakeFileCreationTask < Rake::TestCase
+ include Rake
+ include Rake::DSL
+
+ DUMMY_DIR = 'dummy_dir'
+
+ def setup
+ super
+
+ Task.clear
+ end
+
+ def test_file_needed
+ create_dir DUMMY_DIR
+ fc_task = Task[DUMMY_DIR]
+ assert_equal DUMMY_DIR, fc_task.name
+ FileUtils.rm_rf fc_task.name
+ assert fc_task.needed?, "file should be needed"
+ FileUtils.mkdir fc_task.name
+ assert_equal nil, fc_task.prerequisites.collect{|n| Task[n].timestamp}.max
+ assert ! fc_task.needed?, "file should not be needed"
+ end
+
+ def test_directory
+ directory DUMMY_DIR
+ fc_task = Task[DUMMY_DIR]
+ assert_equal DUMMY_DIR, fc_task.name
+ assert FileCreationTask === fc_task
+ end
+
+ def test_no_retriggers_on_filecreate_task
+ create_timed_files(OLDFILE, NEWFILE)
+ t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
+ t2 = Rake.application.intern(FileCreationTask, NEWFILE)
+ assert ! t2.needed?, "Should not need to build new file"
+ assert ! t1.needed?, "Should not need to rebuild old file because of new"
+ end
+
+ def test_no_retriggers_on_file_task
+ create_timed_files(OLDFILE, NEWFILE)
+ t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
+ t2 = Rake.application.intern(FileCreationTask, NEWFILE)
+ assert ! t2.needed?, "Should not need to build new file"
+ assert ! t1.needed?, "Should not need to rebuild old file because of new"
+ end
+
+ def test_very_early_timestamp
+ t1 = Rake.application.intern(FileCreationTask, OLDFILE)
+ assert t1.timestamp < Time.now
+ assert t1.timestamp < Time.now - 1000000
+ end
+end