diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/test/rake/test_rake_file_creation_task.rb |
Fresh start
Diffstat (limited to 'jni/ruby/test/rake/test_rake_file_creation_task.rb')
-rw-r--r-- | jni/ruby/test/rake/test_rake_file_creation_task.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/jni/ruby/test/rake/test_rake_file_creation_task.rb b/jni/ruby/test/rake/test_rake_file_creation_task.rb new file mode 100644 index 0000000..d8dcd96 --- /dev/null +++ b/jni/ruby/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.map { |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 - 1_000_000 + end +end |